Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/r-lib/commonmark
High Performance CommonMark and Github Markdown Rendering in R
https://github.com/r-lib/commonmark
cmark cmark-gfm gfm markdown
Last synced: about 23 hours ago
JSON representation
High Performance CommonMark and Github Markdown Rendering in R
- Host: GitHub
- URL: https://github.com/r-lib/commonmark
- Owner: r-lib
- License: other
- Created: 2015-05-24T18:58:14.000Z (over 9 years ago)
- Default Branch: main
- Last Pushed: 2024-10-12T17:50:40.000Z (29 days ago)
- Last Synced: 2024-10-26T23:10:46.719Z (15 days ago)
- Topics: cmark, cmark-gfm, gfm, markdown
- Language: C
- Homepage: https://docs.ropensci.org/commonmark/
- Size: 804 KB
- Stars: 88
- Watchers: 8
- Forks: 12
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- Changelog: NEWS
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - r-lib/commonmark - High Performance CommonMark and Github Markdown Rendering in R (C)
README
# commonmark
> High Performance CommonMark and Github Markdown Rendering in R
[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/commonmark)](https://cran.r-project.org/package=commonmark)
[![CRAN RStudio mirror downloads](http://cranlogs.r-pkg.org/badges/commonmark)](https://cran.r-project.org/package=commonmark)The CommonMark specification defines a rationalized version of markdown
syntax. This package uses the 'cmark' reference implementation for converting
markdown text into various formats including html, latex and groff man. In
addition it exposes the markdown parse tree in xml format. The latest version of
this package also adds support for Github extensions including tables, autolinks
and strikethrough text.## Documentation
- [The `commonmark` R package](https://docs.ropensci.org/commonmark/)
- [CommonMark specification for Markdown text](https://commonmark.org/help/)
- [Extensions for GitHub Flavored Markdown](https://github.github.com/gfm/)## Basic Markdown
```r
library(commonmark)
md <- "## Test
An *example* text for the `commonmark` package."# Convert to Latex
cat(markdown_latex(md))
``````
\subsection{Test}An \emph{example} text for the \texttt{commonmark} package.
``````r
# Convert to HTML
cat(markdown_html(md))
``````
Test
An example text for the
commonmark
package.
``````r
# Convert to 'groff' man
cat(markdown_man(md))
``````
.SS
Test
.PP
An \f[I]example\f[] text for the \f[C]commonmark\f[] package.
``````r
# Convert back to (normalized) markdown
cat(markdown_commonmark(md))
``````
## TestAn *example* text for the `commonmark` package.
``````r
# The markdown parse tree
cat(markdown_xml(md))
``````
Test
An
example
text for the
commonmark
package.
```
## Github Extensions
Commonmark includes several 'extensions' to enable features which are not (yet) part of the official specification. The current version of the commonmark R package offers 4 such extensions:
- __table__ support rendering of tables
- __strikethough__ via `~sometext~` syntax
- __autolink__ automatically turn URLs into hyperlinks
- __tagfilter__ blacklist html tags: `title` `textarea` `style` `xmp` `iframe` `noembed` `noframes` `script` `plaintext`.
- __tasklist__ turns certain list items into checkboxes
These extensions were added by Github to support [GitHub Flavored Markdown](https://github.github.com/gfm/).```r
table <- '
aaa | bbb | ccc | ddd | eee
:-- | --- | :-: | --- | --:
fff | ggg | hhh | iii | jjj'cat(markdown_latex(table, extensions = TRUE))
``````
\begin{table}
\begin{tabular}{llclr}
aaa & bbb & ccc & ddd & eee \\
fff & ggg & hhh & iii & jjj \\
\end{tabular}
\end{table}
``````r
cat(markdown_html(table, extensions = TRUE))
``````
aaa
bbb
ccc
ddd
eeefff
ggg
hhh
iii
jjj```