summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/markdown
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2018-04-09 21:09:18 +0000
committerKarl Berry <karl@freefriends.org>2018-04-09 21:09:18 +0000
commit1e0147a88c7bc3a3e2986968f697ef5fbcef2bcb (patch)
tree35ebdb8da7eee58a5bc80c155c61714de0e10683 /Master/texmf-dist/tex/generic/markdown
parent13f04854f4814353751f9cbe298a3ba169ffd972 (diff)
markdown (9apr18)
git-svn-id: svn://tug.org/texlive/trunk@47397 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/generic/markdown')
-rw-r--r--Master/texmf-dist/tex/generic/markdown/markdown.tex110
1 files changed, 69 insertions, 41 deletions
diff --git a/Master/texmf-dist/tex/generic/markdown/markdown.tex b/Master/texmf-dist/tex/generic/markdown/markdown.tex
index 74f1ca40cfb..8b33ee045de 100644
--- a/Master/texmf-dist/tex/generic/markdown/markdown.tex
+++ b/Master/texmf-dist/tex/generic/markdown/markdown.tex
@@ -6,7 +6,7 @@
%%
%% markdown.dtx (with options: `tex')
%%
-%% Copyright (C) 2017 Vít Novotný
+%% Copyright (C) 2018 Vít Novotný
%%
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
@@ -45,8 +45,8 @@
%%
%% The names of the source files used are shown above.
%%
-\def\markdownLastModified{2018/01/08}%
-\def\markdownVersion{2.5.5}%
+\def\markdownLastModified{2018/04/08}%
+\def\markdownVersion{2.5.6}%
\let\markdownBegin\relax
\let\markdownEnd\relax
\let\markdownInput\relax
@@ -75,6 +75,18 @@
\let\markdownOptionSmartEllipses\undefined
\let\markdownOptionStartNumber\undefined
\let\markdownOptionTightLists\undefined
+\def\markdownOptionStripPercentSigns{false}%
+\def\markdownIfOption#1{%
+ \def\next##1##2##3##4##5{%
+ \expandafter\def\expandafter\next\expandafter{%
+ \csname iffalse\endcsname}%
+ \if##1t\if##2r\if##3u\if##4e
+ \expandafter\def\expandafter\next\expandafter{%
+ \csname iftrue\endcsname}%
+ \fi\fi\fi\fi
+ \next}%
+ \expandafter\expandafter\expandafter\next
+ \csname markdownOption#1\endcsname\relax\relax\relax\relax\relax}
\def\markdownRendererInterblockSeparator{%
\markdownRendererInterblockSeparatorPrototype}%
\def\markdownRendererLineBreak{%
@@ -280,8 +292,8 @@
\def\markdownRendererLineBreakPrototype{\hfil\break}%
\let\markdownRendererEllipsisPrototype\dots
\def\markdownRendererNbspPrototype{~}%
-\def\markdownRendererLeftBracePrototype{\char`{}%
-\def\markdownRendererRightBracePrototype{\char`}}%
+\def\markdownRendererLeftBracePrototype{\char`\{}%
+\def\markdownRendererRightBracePrototype{\char`\}}%
\def\markdownRendererDollarSignPrototype{\char`$}%
\def\markdownRendererPercentSignPrototype{\char`\%}%
\def\markdownRendererAmpersandPrototype{\char`&}%
@@ -326,7 +338,7 @@
\def\markdownRendererBlockQuoteBeginPrototype{\par\begingroup\it}%
\def\markdownRendererBlockQuoteEndPrototype{\endgroup\par}%
\def\markdownRendererInputVerbatimPrototype#1{%
- \par{\tt\input"#1"\relax}\par}%
+ \par{\tt\input"#1"\relax{}}\par}%
\def\markdownRendererInputFencedCodePrototype#1#2{%
\markdownRendererInputVerbatimPrototype{#1}}%
\def\markdownRendererHeadingOnePrototype#1{#1}%
@@ -390,7 +402,6 @@
\ifx\markdownOptionInlineFootnotes\undefined\else
inlineFootnotes = \markdownOptionInlineFootnotes,
\fi
- outputDir = "\markdownOptionOutputDir",
\ifx\markdownOptionPreserveTabs\undefined\else
preserveTabs = \markdownOptionPreserveTabs,
\fi
@@ -410,7 +421,7 @@
\def\markdownPrepare{%
local lfs = require("lfs")
local cacheDir = "\markdownOptionCacheDir"
-if lfs.isdir(cacheDir) == true then else
+if not lfs.isdir(cacheDir) then
assert(lfs.mkdir(cacheDir))
end
local md = require("markdown")
@@ -427,36 +438,53 @@ local convert = md.new(\markdownLuaOptions)
\catcode`\^^I=13%
\catcode`|=0%
\catcode`\\=12%
- |gdef|markdownReadAndConvert#1#2{%
- |begingroup%
- |immediate|openout|markdownOutputFileStream%
- |markdownOptionInputTempFileName%
- |markdownInfo{Buffering markdown input into the temporary %
- input file "|markdownOptionInputTempFileName" and scanning %
- for the closing token sequence "#1"}%
- |def|do##1{|catcode`##1=12}|dospecials%
- |catcode`| =12%
- |markdownMakeOther%
- |def|markdownReadAndConvertProcessLine##1#1##2#1##3|relax{%
- |ifx|relax##3|relax%
- |immediate|write|markdownOutputFileStream{##1}%
- |else%
- |def^^M{%
- |markdownInfo{The ending token sequence was found}%
- |immediate|closeout|markdownOutputFileStream%
- |endgroup%
- |markdownInput|markdownOptionInputTempFileName%
- #2}%
- |fi%
- ^^M}%
- |catcode`|^^I=13%
- |def^^I{|markdownReadAndConvertTab}%
- |catcode`|^^M=13%
- |def^^M##1^^M{%
- |def^^M####1^^M{%
- |markdownReadAndConvertProcessLine####1#1#1|relax}%
- ^^M}%
- ^^M}%
+ |catcode`@=14%
+ |catcode`|%=12@
+ |gdef|markdownReadAndConvert#1#2{@
+ |begingroup@
+ |immediate|openout|markdownOutputFileStream@
+ |markdownOptionInputTempFileName@
+ |markdownInfo{Buffering markdown input into the temporary @
+ input file "|markdownOptionInputTempFileName" and scanning @
+ for the closing token sequence "#1"}@
+ |def|do##1{|catcode`##1=12}|dospecials@
+ |catcode`| =12@
+ |markdownMakeOther@
+ |def|markdownReadAndConvertStripPercentSign##1{@
+ |markdownIfOption{StripPercentSigns}@
+ |if##1%@
+ |expandafter|expandafter|expandafter@
+ |markdownReadAndConvertProcessLine@
+ |else@
+ |expandafter|expandafter|expandafter@
+ |markdownReadAndConvertProcessLine@
+ |expandafter|expandafter|expandafter##1@
+ |fi@
+ |else@
+ |expandafter@
+ |markdownReadAndConvertProcessLine@
+ |expandafter##1@
+ |fi}@
+ |def|markdownReadAndConvertProcessLine##1#1##2#1##3|relax{@
+ |ifx|relax##3|relax@
+ |immediate|write|markdownOutputFileStream{##1}@
+ |else@
+ |def^^M{@
+ |markdownInfo{The ending token sequence was found}@
+ |immediate|closeout|markdownOutputFileStream@
+ |endgroup@
+ |markdownInput|markdownOptionInputTempFileName@
+ #2}@
+ |fi@
+ ^^M}@
+ |catcode`|^^I=13@
+ |def^^I{|markdownReadAndConvertTab}@
+ |catcode`|^^M=13@
+ |def^^M##1^^M{@
+ |def^^M####1^^M{@
+ |markdownReadAndConvertStripPercentSign####1#1#1|relax}@
+ ^^M}@
+ ^^M}@
|endgroup
\ifnum\markdownMode<2\relax
\ifnum\markdownMode=0\relax
@@ -502,8 +530,8 @@ local convert = md.new(\markdownLuaOptions)
"|markdownOptionHelperScriptFileName"}%
|immediate|write|markdownOutputFileStream{%
local ran_ok, error = pcall(function()
- local kpse = require('kpse')
- kpse.set_program_name('luatex')
+ local kpse = require("kpse")
+ kpse.set_program_name("luatex")
#1
end)
if not ran_ok then
@@ -542,7 +570,7 @@ local convert = md.new(\markdownLuaOptions)
|closein|markdownInputFileStream
|markdownLuaExecute{%
|markdownPrepare
- local input = assert(io.open("#1","r")):read("*a")
+ local input = assert(io.open("#1", "r"):read("*a"))
print(convert(input:gsub("\r\n?", "\n")))}}%
|endgroup
\endinput