Top Banner
Markdown Péter Jeszenszky Faculty of Informatics, University of Debrecen [email protected] Last modified: September 28, 2020
37

Markdown - unideb.hu · 2019. 11. 3. · Markdown Péter Jeszenszky Faculty of Informatics, University of Debrecen [email protected] Last modified: October 4, 2019

Aug 17, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Markdown - unideb.hu · 2019. 11. 3. · Markdown Péter Jeszenszky Faculty of Informatics, University of Debrecen jeszenszky.peter@inf.unideb.hu Last modified: October 4, 2019

Markdown

Péter JeszenszkyFaculty of Informatics, University of Debrecen

[email protected]

Last modified: September 28, 2020

Page 2: Markdown - unideb.hu · 2019. 11. 3. · Markdown Péter Jeszenszky Faculty of Informatics, University of Debrecen jeszenszky.peter@inf.unideb.hu Last modified: October 4, 2019

2

Markup Languages

● Markup languages are computer languages for annotating text.– They allow the association of metadata with parts of text in a

clearly distinguishable way.● Examples:

– TeX, LaTeX https://www.latex-project.org/– Markdown https://daringfireball.net/projects/markdown/– troff (man pages) https://www.gnu.org/software/groff/– XML https://www.w3.org/XML/– Wikitext https://en.wikipedia.org/wiki/Help:Wikitext

Page 3: Markdown - unideb.hu · 2019. 11. 3. · Markdown Péter Jeszenszky Faculty of Informatics, University of Debrecen jeszenszky.peter@inf.unideb.hu Last modified: October 4, 2019

3

What is Markdown?

● Markdown is a lightweight markup language with plain text formatting syntax.– See: https://en.wikipedia.org/wiki/Markdown

Page 4: Markdown - unideb.hu · 2019. 11. 3. · Markdown Péter Jeszenszky Faculty of Informatics, University of Debrecen jeszenszky.peter@inf.unideb.hu Last modified: October 4, 2019

4

Symbol

● Dustin Curtis. The Markdown Mark. https://dcurt.is/the-markdown-mark https://github.com/dcurtis/markdown-mark

Page 5: Markdown - unideb.hu · 2019. 11. 3. · Markdown Péter Jeszenszky Faculty of Informatics, University of Debrecen jeszenszky.peter@inf.unideb.hu Last modified: October 4, 2019

5

Characteristics

● An easy-to-read and easy-to-write plain text format that.

● Can be converted to various output formats (e.g., HTML).

● Specifically targeted at non-technical users.● The syntax is mostly inspired by the format of

plain text email.

Page 6: Markdown - unideb.hu · 2019. 11. 3. · Markdown Péter Jeszenszky Faculty of Informatics, University of Debrecen jeszenszky.peter@inf.unideb.hu Last modified: October 4, 2019

6

Usage (1)

● Markdown is widely used on the web for entering text.

● The main application areas include:– Collaboration platforms and tools– Blogging platforms and content management

systems– Online community platforms– Technical and scientific publishing

Page 7: Markdown - unideb.hu · 2019. 11. 3. · Markdown Péter Jeszenszky Faculty of Informatics, University of Debrecen jeszenszky.peter@inf.unideb.hu Last modified: October 4, 2019

7

Usage (2)

● Collaboration platforms and tools:– GitHub https://github.com/

● See: Writing on GitHub https://help.github.com/en/categories/writing-on-github

– Trello https://trello.com/● See: How To Format Your Text in Trello

https://help.trello.com/article/821-using-markdown-in-trello

Page 8: Markdown - unideb.hu · 2019. 11. 3. · Markdown Péter Jeszenszky Faculty of Informatics, University of Debrecen jeszenszky.peter@inf.unideb.hu Last modified: October 4, 2019

8

Usage (3)

● Blogging platforms and content management systems:– Moodle https://moodle.org/

● See: https://docs.moodle.org/en/Markdown

– WordPress https://wordpress.com/● See: Using Markdown on WordPress.com

https://en.support.wordpress.com/can-i-use-markdown-on-wordpress-com/

Page 9: Markdown - unideb.hu · 2019. 11. 3. · Markdown Péter Jeszenszky Faculty of Informatics, University of Debrecen jeszenszky.peter@inf.unideb.hu Last modified: October 4, 2019

9

Usage (4)

● Online community platforms:– reddit https://www.reddit.com/

● See: https://www.reddit.com/wiki/markdown

– Stack Overflow https://stackoverflow.com/● See: How do I format my posts using Markdown or

HTML? https://stackoverflow.com/help/formatting

Page 10: Markdown - unideb.hu · 2019. 11. 3. · Markdown Péter Jeszenszky Faculty of Informatics, University of Debrecen jeszenszky.peter@inf.unideb.hu Last modified: October 4, 2019

10

Usage (5)

● Technical and scientific publishing:– bookdown https://bookdown.org/– Daniel Stenberg. Everything curl.

https://curl.haxx.se/book.html https://github.com/bagder/everything-curl

– GitBook https://www.gitbook.com/● See: https://docs.gitbook.com/content-editing/markdown

– Microsoft Docs https://docs.microsoft.com/● See: Docs Markdown reference

https://docs.microsoft.com/en-us/contribute/markdown-reference

Page 11: Markdown - unideb.hu · 2019. 11. 3. · Markdown Péter Jeszenszky Faculty of Informatics, University of Debrecen jeszenszky.peter@inf.unideb.hu Last modified: October 4, 2019

11

History (1)

● Originally, Markdown was developed in 2004 by John Gruber with contributions from Aaron Swartz.– It was a created in the form of:

● a plain text format for writing structured documents, and● a Perl script to convert Markdown to HTML

(Markdown.pl).

● Website: https://daringfireball.net/projects/markdown/

Page 12: Markdown - unideb.hu · 2019. 11. 3. · Markdown Péter Jeszenszky Faculty of Informatics, University of Debrecen jeszenszky.peter@inf.unideb.hu Last modified: October 4, 2019

12

History (2)

● About the motivation behind the creation of Markdown:– John Gruber. Dive Into Markdown. 19 March 2004.

https://daringfireball.net/2004/03/dive_into_markdown

● The original Markdown syntax: https://daringfireball.net/projects/markdown/syntax– The syntax is not specified unambiguously.

Page 13: Markdown - unideb.hu · 2019. 11. 3. · Markdown Péter Jeszenszky Faculty of Informatics, University of Debrecen jeszenszky.peter@inf.unideb.hu Last modified: October 4, 2019

13

File Properties

● File extension: .md

● Media type: text/markdown

– Optional parameter: variant

● See: Sean Leonard. The text/markdown Media Type. RFC 7763. March 2016. https://tools.ietf.org/html/rfc7763

Page 14: Markdown - unideb.hu · 2019. 11. 3. · Markdown Péter Jeszenszky Faculty of Informatics, University of Debrecen jeszenszky.peter@inf.unideb.hu Last modified: October 4, 2019

14

Syntactic Ambiguities (1)

● For a comprehensive list of syntactic ambiguities, see:– CommonMark Spec – Why is a spec needed?

https://spec.commonmark.org/0.29/#why-is-a-spec-needed-

● A possible option to resolve these ambiguities is to consult the source code of Gruber's implementation (i.e., Markdown.pl).– Unfortunately, it was quite buggy.

Page 15: Markdown - unideb.hu · 2019. 11. 3. · Markdown Péter Jeszenszky Faculty of Informatics, University of Debrecen jeszenszky.peter@inf.unideb.hu Last modified: October 4, 2019

15

Syntactic Ambiguities (2)

● Babelmark 2https://johnmacfarlane.net/babelmark2/– A tool for comparing the output of various

implementations of the original Markdown syntax.

Page 16: Markdown - unideb.hu · 2019. 11. 3. · Markdown Péter Jeszenszky Faculty of Informatics, University of Debrecen jeszenszky.peter@inf.unideb.hu Last modified: October 4, 2019

16

Standardization

● CommonMark https://commonmark.org/– A standard, unambiguous syntax specification for

Markdown.– Specification: CommonMark Spec

https://spec.commonmark.org/● Provides a test suite to validate implementations against

the specification.

Page 17: Markdown - unideb.hu · 2019. 11. 3. · Markdown Péter Jeszenszky Faculty of Informatics, University of Debrecen jeszenszky.peter@inf.unideb.hu Last modified: October 4, 2019

17

Variants

● Several variants and extensions of Markdown exist, for example:– GitHub Flavored Markdown (GFM)

● See: GitHub Flavored Markdown Spec https://github.github.com/gfm/

– Pandoc's Markdown● See: Pandoc User’s Guide – Pandoc's Markdown

https://pandoc.org/MANUAL.html#pandocs-markdown

– …● See: Markdown Variants

https://www.iana.org/assignments/markdown-variants/markdown-variants.xhtml

Page 18: Markdown - unideb.hu · 2019. 11. 3. · Markdown Péter Jeszenszky Faculty of Informatics, University of Debrecen jeszenszky.peter@inf.unideb.hu Last modified: October 4, 2019

18

Tutorials

● Markdown Guide https://www.markdownguide.org/

● Markdown Tutorial https://commonmark.org/help/tutorial/

Page 19: Markdown - unideb.hu · 2019. 11. 3. · Markdown Péter Jeszenszky Faculty of Informatics, University of Debrecen jeszenszky.peter@inf.unideb.hu Last modified: October 4, 2019

19

Editors (1)

● Free and open source software:– Visual Studio Code (platform: Linux, macOS, Windows;

license: MIT License) https://code.visualstudio.com/ https://github.com/Microsoft/vscode

● See: https://code.visualstudio.com/docs/languages/markdown

● Recommended extensions:– Markdown All in One

https://marketplace.visualstudio.com/items?itemName=yzhang.markdown-all-in-one

– Markdown+Math https://marketplace.visualstudio.com/items?itemName=goessner.mdmath

Page 20: Markdown - unideb.hu · 2019. 11. 3. · Markdown Péter Jeszenszky Faculty of Informatics, University of Debrecen jeszenszky.peter@inf.unideb.hu Last modified: October 4, 2019

20

Editors (2)

● Free and open source software (continued):– ghostwriter (platform: Linux, Windows; written in: C++; license:

GPLv3) http://wereturtle.github.io/ghostwriter/ https://github.com/wereturtle/ghostwriter

– Mark Text (platform: Linux, macOS, Windows; written in: JavaScript; license: MIT License) https://marktext.app/ https://github.com/marktext/marktext

– Remarkable (platform: Linux; written in: Python; license: MIT License) http://remarkableapp.github.io/ https://github.com/jamiemcg/remarkable

– StackEdit (written in: JavaScript; license: Apache License 2.0) https://stackedit.io/ https://github.com/benweet/stackedit

Page 21: Markdown - unideb.hu · 2019. 11. 3. · Markdown Péter Jeszenszky Faculty of Informatics, University of Debrecen jeszenszky.peter@inf.unideb.hu Last modified: October 4, 2019

21

Editors (3)

● Non-free software:– <oXygen/> XML Editor https://www.oxygenxml.com/

● See: https://www.oxygenxml.com/xml_editor/markdown_editor.html

– IntelliJ IDEA https://www.jetbrains.com/idea/● Supported in Ultimate and Community Editions.● See: https://www.jetbrains.com/help/idea/markdown.html

Page 22: Markdown - unideb.hu · 2019. 11. 3. · Markdown Péter Jeszenszky Faculty of Informatics, University of Debrecen jeszenszky.peter@inf.unideb.hu Last modified: October 4, 2019

22

Conversion Tools

● Free and open source software:– Pandoc (platform: Linux, macOS, Windows; license:

GPLv2) https://pandoc.org/ https://github.com/jgm/pandoc

● A command-line tool written in Haskell to convert files from one markup format into another.

● Markdown is supported both as source and target formats.

Page 23: Markdown - unideb.hu · 2019. 11. 3. · Markdown Péter Jeszenszky Faculty of Informatics, University of Debrecen jeszenszky.peter@inf.unideb.hu Last modified: October 4, 2019

23

Pandoc (1)

● Installation: https://pandoc.org/installing.html● Use: https://pandoc.org/MANUAL.html

pandoc --standalone --to html input.md \--output output.html --css style.css

or

pandoc -s -t html input.md -o output.html \-c style.css

Page 24: Markdown - unideb.hu · 2019. 11. 3. · Markdown Péter Jeszenszky Faculty of Informatics, University of Debrecen jeszenszky.peter@inf.unideb.hu Last modified: October 4, 2019

24

Pandoc (2)

● Styling the output with CSS:– The -c/--css command line option associates a

custom CSS stylesheet with the output document.● This option can be used repeatedly.

Page 25: Markdown - unideb.hu · 2019. 11. 3. · Markdown Péter Jeszenszky Faculty of Informatics, University of Debrecen jeszenszky.peter@inf.unideb.hu Last modified: October 4, 2019

25

Pandoc (3)

● Examples of custom CSS stylesheets:– Pan Am: Simple CSS for Pandoc (license: WTFPL)

https://benjam.info/pan-am/ https://github.com/bgw/pan-am

● CSS stylesheet: http://benjam.info/panam/styling.css

– Tufte Pandoc CSS (license: MIT License) https://jez.io/tufte-pandoc-css/ https://github.com/jez/tufte-pandoc-css

Page 26: Markdown - unideb.hu · 2019. 11. 3. · Markdown Péter Jeszenszky Faculty of Informatics, University of Debrecen jeszenszky.peter@inf.unideb.hu Last modified: October 4, 2019

26

Pandoc (4)

● IDE integration:– Visual Studio Code:

● vscode-pandoc https://github.com/dfinke/vscode-pandoc https://marketplace.visualstudio.com/items?itemName=DougFinke.vscode-pandoc

Page 27: Markdown - unideb.hu · 2019. 11. 3. · Markdown Péter Jeszenszky Faculty of Informatics, University of Debrecen jeszenszky.peter@inf.unideb.hu Last modified: October 4, 2019

27

R Markdown (1)

● R Markdown is an extension of Markdown that enables the embedding of executable code chunks.– For example, the following languages are

supported: Apache Groovy, Bash, Haskell, Python, R, Scala, SQL, …

● File extension: .Rmd● Website: https://rmarkdown.rstudio.com/

Page 28: Markdown - unideb.hu · 2019. 11. 3. · Markdown Péter Jeszenszky Faculty of Informatics, University of Debrecen jeszenszky.peter@inf.unideb.hu Last modified: October 4, 2019

28

R Markdown (2)

● R Markdown is implemented as an R package (rmarkdown). https://cran.r-project.org/web/packages/rmarkdown/

Page 29: Markdown - unideb.hu · 2019. 11. 3. · Markdown Péter Jeszenszky Faculty of Informatics, University of Debrecen jeszenszky.peter@inf.unideb.hu Last modified: October 4, 2019

29

R Markdown (3)

● Supported output formats: HTML, PDF, PowerPoint, MS Word, …

● Creating PDF output requires a TeX installation.– For the list of available options, see:

https://www.latex-project.org/get/#tex-distributions – The easiest way of installing TeX for R users:

● TinyTeX https://yihui.org/tinytex/– A lightweight, cross-platform, portable TeX distribution based on TeX Live.– The tinytex R package is provided for installing TinyTeX. The

installation does not require administrator privileges.

Page 30: Markdown - unideb.hu · 2019. 11. 3. · Markdown Péter Jeszenszky Faculty of Informatics, University of Debrecen jeszenszky.peter@inf.unideb.hu Last modified: October 4, 2019

30

R Markdown (4)

● Documentation:– Yihui Xie, J. J. Allaire, Garrett Grolemund. R

Markdown: The Definitive Guide. 2019. https://bookdown.org/yihui/rmarkdown/ https://github.com/rstudio/rmarkdown-book

● Tool support:– RStudio https://www.rstudio.com/

Page 31: Markdown - unideb.hu · 2019. 11. 3. · Markdown Péter Jeszenszky Faculty of Informatics, University of Debrecen jeszenszky.peter@inf.unideb.hu Last modified: October 4, 2019

31

R Markdown (5)

● The rmarkdown packages depends on the knitr package.

– knitr is an R package for dynamic report generation.

– It is used to evaluate computer code embedded in Markdown and to include the result.

– Website: https://yihui.org/knitr/ https://github.com/yihui/knitr

Page 32: Markdown - unideb.hu · 2019. 11. 3. · Markdown Péter Jeszenszky Faculty of Informatics, University of Debrecen jeszenszky.peter@inf.unideb.hu Last modified: October 4, 2019

32

R Markdown (6)

● Conversion:

file.Rmd knitr file.md pandoc file.html

file.doc

file.pdf

Page 33: Markdown - unideb.hu · 2019. 11. 3. · Markdown Péter Jeszenszky Faculty of Informatics, University of Debrecen jeszenszky.peter@inf.unideb.hu Last modified: October 4, 2019

33

R Markdown (7)

---title: "R Markdown Example"author: Péter Jeszenszkyoutput: html_document---

```{r setup, include = FALSE}knitr::opts_chunk$set(echo = TRUE)```

# Using LaTeX and R

Plot of the function $f(x) = sin(x) + cos(\sqrt{3}x)$:```{r}library(ggplot2)f <- function(x) sin(x) + cos(sqrt(3) * x)ggplot(data.frame(x = 0), aes(x)) + stat_function(fun = f, colour = "blue") + xlim(-2 * pi, 2 * pi)```

Page 34: Markdown - unideb.hu · 2019. 11. 3. · Markdown Péter Jeszenszky Faculty of Informatics, University of Debrecen jeszenszky.peter@inf.unideb.hu Last modified: October 4, 2019

34

Page 35: Markdown - unideb.hu · 2019. 11. 3. · Markdown Péter Jeszenszky Faculty of Informatics, University of Debrecen jeszenszky.peter@inf.unideb.hu Last modified: October 4, 2019

35

R Markdown (9)

● bookdown:– An R package for writing books and long-form articles/reports with R

Markdown.– It supports multiple output formats: PDF, LaTeX, HTML, EPUB, MS

Word.– It also supports the inclusion of dynamic graphics and interactive

applications.– It supports the use of LaTeX math formulas with each output format.

– The list of books written with bookdown can be found at the website of the package.

– Website: https://bookdown.org/– Documentation: https://bookdown.org/yihui/bookdown/

Page 36: Markdown - unideb.hu · 2019. 11. 3. · Markdown Péter Jeszenszky Faculty of Informatics, University of Debrecen jeszenszky.peter@inf.unideb.hu Last modified: October 4, 2019

36

Examples

● https://github.com/jeszy75/markdown-examples

Page 37: Markdown - unideb.hu · 2019. 11. 3. · Markdown Péter Jeszenszky Faculty of Informatics, University of Debrecen jeszenszky.peter@inf.unideb.hu Last modified: October 4, 2019

37

Further Reading

● Sean Leonard. Guidance on Markdown: Design Philosophies, Stability Strategies, and Select Registrations. RFC 7764. March 2016. https://tools.ietf.org/html/rfc7764