Releases: kubaPod/M2MD
Set of fixes
Updates, updates
Features/changes
-
"BoxesToStringType" -> "InputText"
option determines how cells with code are converted to text.
It accepts whateverExportPacket
accepts."InputText"
respects automatic indentation of input cells, pads operators with whitespaces, - with comparison to"PlainText"
."PlainText"
respects infinite page width while"InputText"
breaks lines around 70th char
The default was changed from PlainText because most folks use Input style cells anyway.
-
"CodeLanguage" -> "mathematica"
Code/Input and InputForm language. It used to bewl
but it is more likely thatmathematica
will be the recognized one.
Fixes/updates
ExportMD
always exportsUTF8
text.- Code block language for ExternalLanguage cells
- Better handling of hyperlink created via Insert>Hyperlink menu
- Handling InputForm output
Out/In[]:=
labels are now ignored when exporting cell as text.\[LongRightArrow]
and similar operators are no longer replaced with ASCII forms. (because they can not be reversed)
CellStyleRules
CellStyleRules options allows you to customize converter:
M2MD[ Cell["Test", "MyStyle"]]
M2MD[ Cell["Test", "MyStyle"], "CellStyleRules" -> <|"MyStyle" -> "h1"|>]
M2MD[ Cell["Test", "MyStyle"], "CellStyleRules" -> <|"MyStyle" -> {"h1", BoxesToTeXString[#]&}|>]
M2MD[ Cell["Test", "MyStyle"], "CellStyleRules" -> <|"MyStyle" -> {"h1", ToImageElement[#]&}|>]
Out[17]= "Test"
Out[18]= "# Test"
Out[19]= "# \\text{Test}"
Out[20]= "# ![0tcrut3pb10j4](img\\0tcrut3pb10j4.png)"
Specification {tag_, parsers___}
translates to MDElement[tag, parser1[cell_, style_], parser2[cell_, style_], ___]
Built-in parsers :
BoxesToMDString
BoxesToInputString
ToImageElement
BoxesToTeXString
But you can use whatever you want as long as it returns something that MDElementTemplate
for given tag can handle.
We can go even further and define a brand new conversion:
M2MD[ Cell["Test", "MyStyle"],
"CellStyleRules" -> <|"MyStyle" -> "myTag"|>,
"MDElementTemplates" -> <|"myTag" -> "# ((((``))))\n---"|>
]
Out[25]= "# ((((Test))))
---"
More conversion rules
v0.4.0 More conversion rules
Inline cells handling
v0.3.0 Inline cells handling
New options
"OverwriteImages" -> True|False
Since images automatic names are based on expression hash we can avoid repeated exporting of them. By default an image won't be exported if nothing changed. That option can force it to export anyway.
MDElementTemplates
"MDElementTemplates" -> KeyValuePattern[{ mdTag_String -> template:_String|_TemplateObject }]
The converter first creates a symbolic representation of a markdown which uses MDElement["h1", "a title"]
and this option allows us to overwrite existing rules by which it is translated to the final string.
Currently used MD element rules are:
<|
"LaTeXBlock" -> "$$``$$"
, "LaTeXInline"-> "$``$"
, "Image" -> "![``](``)"
, "Hyperlink" -> "[``](``)"
, "Text" -> "``"
, "Bold" -> "**``**"
, "Italic" -> "*``*"
, "h1" -> "# <*StringReplace[#, \"\n\"->\"<br>\"]*>"
, "h2" -> "## <*StringReplace[#, \"\n\"->\"<br>\"]*>"
, "h3" -> "### <*StringReplace[#, \"\n\"->\"<br>\"]*>"
, "h4" -> "#### <*StringReplace[#, \"\n\"->\"<br>\"]*>"
, "h5" -> "##### <*StringReplace[#, \"\n\"->\"<br>\"]*>"
, "h6" -> "###### <*StringReplace[#, \"\n\"->\"<br>\"]*>"
, "Comment" -> "[//]: # (``)"
, "CodeBlock" -> TemplateExpression @ StringJoin["```mathematica\n", TemplateSlot[1], "\n```"]
, "Output" -> TemplateExpression @ StringJoin["```\n(*", TemplateSlot[1], "*)\n```"]
|>;
Updates
Set of updates
- It used to be that unknown cell styles were not converted at all, now by default it tries to convert them to a simple text element (TextData) or as an image (BoxData).
\[Rule]
and friends replaced by ASCII equivalents"IgnoredStyles"
optionpaclet:ref/Symbol
hyperlinks translated to WRI online documentation links
Set of fixes
v0.2.2 Set of fixes
Small fixes
v0.2.1 Automatic image export dir fixed