Render Markdown with the C Library 'Sundown'

Provides R bindings to the 'Sundown' Markdown rendering library (<>). Markdown is a plain-text formatting syntax that can be converted to 'XHTML' or other formats. See <> for more information about Markdown.

Build Status Downloads from the RStudio CRAN mirror


Markdown is a plain-text formatting syntax that can be converted to XHTML or other formats. This package provides R bindings to the Sundown markdown rendering library.

The R function markdownToHTML renders a markdown file to HTML. Options controlling HTML output and supported markdown extensions can be optionally specified.

The package also exports the underlying Sundown C extension API which enables creating and calling custom renderers using the renderMarkdown function.

To learn more about markdown syntax see:

This package is referred to as R Markdown v1 when combined with knitr. The primary output format is HTML. We do not plan to add new features to this package in the future, and please consider this package to be in the maintenance mode only. In 2014, we introduced R Markdown v2, which is based on Pandoc and knitr, and supports much more types of output formats. Please see for details.


The markdown package is licensed under the GPLv2. See these files for additional details:

  • inst/COPYING - Markdown package license (GPLv2)
  • inst/NOTICE - Copyright notices for additional included software


		      CHANGES IN markdown VERSION 0.9


o Fixed clang-UBSAN and valgrind issues (thanks, @yixuan, #92).

		      CHANGES IN markdown VERSION 0.8


o the MathJax CDN URL was replaced by


o fixed markdownToHTML() did not work with empty files (thanks, @VermillionAzure)

		      CHANGES IN markdown VERSION 0.7.7


o renderMarkdown() works now even if text = character(0) or ""

o added an encoding argument to renderMarkdown() since multi-byte characters in renderMarkdown() did not work on Windows (thanks, Kohske Takahashi, #63)

o fixed #64: invalid 'n' argument in rpubsUpload() (thanks, Wouter van Atteveldt)


o if renderMarkdown() returns a character vector, it will be marked with the UTF-8 encoding if it contains multi-byte characters

		      CHANGES IN markdown VERSION 0.7.4


o when an image is the only element of its parent node in the HTML output document, it is automatically centered on the page


o images that have already been base64 encoded will not be encoded again (#61)

o the URL of the MathJax CDN was updated to

		      CHANGES IN markdown VERSION 0.7.2


o fixed #60: MathJax may be included even if it is unnecessary when syntax highlighting is enabled (thanks, @aoles)

o fixed a bug which may hang R when building R Markdown vignettes in a wrong locale (thanks, Dan Tenenbaum, yihui/knitr#782)

		      CHANGES IN markdown VERSION 0.7


o if both the 'file' and 'text' arguments are provided but file = NULL, e.g. markdownToHTML(file = NULL, text = ?), markdownToHTML() can throw an error indicating the file is invalid (thanks, Tyler Rinker, hadley/staticdocs#66)

o markdownToHTML(text = ?, output = ?) was broken (#54)

		      CHANGES IN markdown VERSION 0.6.5


o added an argument 'encoding' to markdownToHTML() to specify the character encoding of the input markdown file, and the HTML output file is always encoded in UTF-8 now (thanks, Kohske Takahashi, #50)

		      CHANGES IN markdown VERSION 0.6.4


o added 'mathjax_embed' to HTML options for embedding the MathJax JavaScript in the HTML document rather than linking to it online. Note the JavaScript code is read from the http instead of https MathJax URL. Contributed by Henrik Bengtsson.

o added another vignette to show the HTML output of the original vignette (see browseVignettes('markdown'))

o the default CSS style was tweaked (major changes include: page width is at most 800px, more line height, slightly larger fonts, and a different syntax highlighting theme)

		      CHANGES IN markdown VERSION 0.6.3


o added a new argument 'template' to markdownToHTML() so that we can customize the HTML template (by default, it uses the template 'resources/markdown.html' in this package); thanks, Nacho Caballero

o the options markdown.HTML.stylesheet and markdown.HTML.header used in markdownToHTML() can be character vectors (they will be processed by paste(x, collapse = '\n')


o the 'text' argument in markdownToHTML() and renderMarkdown() is treated as lines of input now, i.e. if 'text' is provided, it is passed to the markdown renderer as paste(text, collapse = '\n'); in the previous versions, it was processed by paste(text, collapse = '')

		      CHANGES IN markdown VERSION 0.6


o added a package vignette; see browseVignettes(package = 'markdown')

		      CHANGES IN markdown VERSION 0.5.5


o added a new argument 'header' to markdownToHTML() to insert code into the HTML header (e.g. custom CSS styles)


o fixed #25 and #27: minor documentation problems

o fixed #26: the HTML output file will be written relative to the current working directory now when it contains images that need to be base64 encoded

o fixed #28: the image URL should be decoded before the image is based64 encoded


o Yihui Xie has taken over the maintainership for this package from Jeffrey Horner

		      CHANGES IN markdown VERSION 0.5.4


o Both Pandoc title blocks and Jekyll front matter sections are skipped when rendering markdown documents.

		      CHANGES IN markdown VERSION 0.5.3


o C/C++ is now a supported language for code block highlighting.


o 'hard_wrap' has been dropped while 'mathjax' and 'highlight_code' have been added to the default list of html options.


o fixed parsing of math equations when located at the end of a line.

		      CHANGES IN markdown VERSION 0.5.2


o with the new 'latex_math' markdown extensions, users can include math equations using several syntaxes. For block level equations, use $$latex ... $$, $$ ... $$, or [ ... ]. For inline equations, use $latex...$, $...$, or ( ... ).


o the markdown extension 'ingore_math' was replaced with 'latex_math'.

o users can now use the markdown.HTML.stylesheet option to override the package default stylesheet.

o setting the fragment_only rendering option or the fragment.only parameter to markdownToHTML will base64 encode images if applicable. version 0.5.1 did not.

		      CHANGES IN markdown VERSION 0.5.1


o fixed a GUIDgenerator bug; for escaping math equations before markdown parsing begins.

o image encoding was fixed for the case when there are more than one included in a markdown document.

		      CHANGES IN markdown VERSION 0.5


o added fragment.only parameter to markdownToHTML

o added new html rendering options base64_images, fragment_only, mathjax, and highlight_code

o added new markdown extension ignore_math


o removed safelink from default html rendering options

o the default html rendering options are now hard_wrap, use_xhtml, smartypants, and base64_images.


o fixed syntax errors in C exports

		      CHANGES IN markdown VERSION 0.4


o added support for post-processing HTML using smartypants filter

o added optional support for rendering a table of contents


o changed exported C functions to use an rmd_ prefix (eliminating potential symbol conflicts with other packages)

o changed default html rendering options to use_xhtml, hard_wrap, safelink, and smartypants


o eliminated name collision with render_markdown function in knitr

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


1.1 by Yihui Xie, 2 years ago

Report a bug at

Browse source code at

Authors: JJ Allaire [aut] , Jeffrey Horner [aut] , Yihui Xie [aut, cre] , Henrik Bengtsson [ctb] , Jim Hester [ctb] , Yixuan Qiu [ctb] , Kohske Takahashi [ctb] , Adam November [ctb] , Nacho Caballero [ctb] , Jeroen Ooms [ctb] , Thomas Leeper [ctb] , Joe Cheng [ctb] , Andrzej Oles [ctb] , Vicent Marti [aut, cph] (The Sundown library) , Natacha Porte [aut, cph] (The Sundown library) , RStudio [cph]

Documentation:   PDF Manual  

Task views: Reproducible Research

GPL-2 license

Imports utils, xfun, mime

Suggests knitr, RCurl

Imported by BENMMI, GRANBase, IOHanalyzer, ReDaMoR, Rfssa, SPARTAAS, TKCat, airGRteaching, caffsim, checkdown, confidence, coveffectsplot, dataCompareR, datamart, dccvalidator, devtoolbox, dowser, ezknitr, ggquickeda, gitgadget, gridtext, jgcricolors, knitrBootstrap, leaflet, learnr, markdownInput, miniMeta, mirtCAT, plumbertableau,, rock, scCAN, shinyhelper, shinystan, teachingApps, tutorial, wpa.

Depended on by EasyHTMLReport, SOMbrero, exsic, reverseR, stmgui.

Suggested by AUtests, AirSensor, AnaCoDa, AssetCorr, AugmenterR, BAwiR, BayesFactor, BayesianFROC, CSIndicators, CSTools, ClimProjDiags, DAMisc, DCLEAR, DMtest, DisImpact, DockerParallel, EDOIF, EFDR, EGAnet, EHR, EPP, Ecfun, EmpiricalCalibration, FactoMineR, FeatureTerminatoR, FishPhyloMaker, ForeCA, GetoptLong, GlarmaVarSel, GlobalOptions, HSAR, HotellingEllipse, IRexamples, IgAScores, JSmediation, LambertW, LoopDetectR, MRReg, MSiP, MVNtestchar, MXM, ManagedCloudProvider, MazamaCoreUtils, MazamaLocationUtils, MazamaRollUtils, MazamaSpatialPlots, MazamaSpatialUtils, MetaClean, MoMPCA, MultIS, NGLVieweR, OddsPlotty, PINSPlus, PLFD, PeakSegDisk, R.rsp, RDFTensor, RRTCS, RRphylo, RTIGER, Randomuseragent, Rcatch22, Rcmdr, RedisBaseContainer, RefManageR, Revticulate, Rvmmin, SCEM, SDMPlay, SDraw, SemNetCleaner, SemNetDictionaries, SingleCaseES, SoilTaxonomy, SpatialBSS, SpatialEpi, VLTimeCausality, WLasso, WikidataR, ZIprop, aSPU, adegraphics, admix, airGR, aldvmm, amanida, archivist, argoFloats, assemblerr, assertive, asteRisk, auditor, autoplotly, babette, bayesplay, baytrends, bcROCsurface, beastier, beautier, bioacoustics, bkmrhat, bootPLS, brolgar, bsub, bumblebee, caRamel, cellWise, chipPCR, chirps, circlize, cleangeo, cmna, colorBlindness, combiroc, comsimitv, confSAM,, cry, csvwr, cwbtools, dad, dagitty, dataquieR, daymetr, derivmkts, directlabels, doFuture, dodgr, dpseg, ecodist, economiccomplexity, ecospat, ensembleTax, eoffice, epca, esaddle, etrm, eurostat, evaluator, fairadapt, fcaR, ffp, fishtree, freealg, frenchdata, future, future.apply, future.batchtools, future.callr, gWQS, gdistance, geckor, gen3sis, geocmeans, ggfortify, ggmulti, ggplotAssist, ggpval, ggraptR, ggstar, ggx, glmpca, gluedown, glycanr, googleVis, graphsim, gsEasy, gtfs2gps, gtfsrouter, hadron, hakaiApi, highr, hpiR, htmltools, hwsdr, hyperoverlap, hysteresis, importinegi, inferference, insee, jackalope, jrvFinance, kfigr, kinematics, klic, knitr, latentcor, ldamatch, leiden, link2GI, listenv, lmtp, logitnorm, lognorm, loon.tourr, macleish, manymodelr, mapmisc, markophylo, matlib, matrixStats, mauricer, mcprofile, mde, medExtractR, medicaldata, metropolis, microbial, microplot, mirt, missMDA, mistral, modifiedmk, move, mpcmp, multipanelfigure, nat, natstrat, nc, netplot, nhdplusTools, njtr1, nlsr, nprcgenekeepr, oai, odr, onbrand, openSkies, optimx, optmatch, orderly, osmdata, osmgeosample, pacviz, paleopop, pangaear, passt, philentropy, phonics, pixarfilms, pkgmaker, polmineR, profmem, psrwe, ptm, ptspotter, qgcomp, qgcompint, qpNCA, qsimulatR, rADA, radiant, radiant.basics, ratematrix, rbokeh, rco, rdaemon, rdnb, readabs, regsem, resevol, retroharmonize, rgl, rglobi, rpf, rpmodel, rsdmx, rslurm, rsnps, runjags, sageR, sasMap, scdhlm, selection.index, sen2r, shapper, shiny, sigminer, simrel, sivs, smd, sotkanet, spacetime, spatsoc, sphunif, stabiliser, statnipokladna, stokes, strm, sunburstR, survRatio, survminer, survxai, svDialogs, svGUI, svMisc, svUnit, svyVGAM, synlik, tRnslate, targets, tastypie, testarguments, text.alignment, tidyMicro, tidygate, tidyseurat, tidytransit, tmplate, tracerer, treeDA, treemap, tvm, uavRmp, uklr, univariateML, utiml, valmetrics, vapour, varrank, vegan, visualpred, vprr, wavemulcor, wbstats, whisker, wildviz, wordpredictor, wsrf, xfun, xutils, yowie, zebu, zipcodeR.

See at CRAN