Skip to content

Releases: kubaPod/M2MD

Set of fixes

27 Nov 10:02
Compare
Choose a tag to compare
  • code input form formatting improved
  • ImagesFetchURL fix for URL[_] setting

Updates, updates

04 Feb 09:01
Compare
Choose a tag to compare

Features/changes

  • "BoxesToStringType" -> "InputText" option determines how cells with code are converted to text.
    It accepts whatever ExportPacket 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 be wl but it is more likely that mathematica will be the recognized one.

Fixes/updates

  • ExportMD always exports UTF8 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

31 Jan 12:35
Compare
Choose a tag to compare
CellStyleRules Pre-release
Pre-release

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

30 Jan 14:05
Compare
Choose a tag to compare
More conversion rules Pre-release
Pre-release
v0.4.0

More conversion rules

Inline cells handling

27 Jan 11:07
Compare
Choose a tag to compare
v0.3.0

Inline cells handling

New options

21 Jan 07:43
Compare
Choose a tag to compare

"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.

image

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

20 Jan 16:07
Compare
Choose a tag to compare
Updates Pre-release
Pre-release
  • more pragmatic CellStyle to MD headers (see #1 )
  • operators named characters (see #2 )
  • persistent image names with automatic names based on expression hash

Set of updates

17 Jan 11:53
Compare
Choose a tag to compare
Set of updates Pre-release
Pre-release
  • 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" option
  • paclet:ref/Symbol hyperlinks translated to WRI online documentation links

Set of fixes

13 Jan 13:50
Compare
Choose a tag to compare
Set of fixes Pre-release
Pre-release
v0.2.2

Set of fixes

Small fixes

13 Jan 07:18
Compare
Choose a tag to compare
v0.2.1

Automatic image export dir fixed