110. unmarkdown

No parameter.

Replace Markdown markup found all the text nodes of explicitly or implicitly selected element by equivalent XML elements. Supported Markdown markup: italic, bold, bold and italic, code, strikethrough, highlight, subscript, superscript, link, image, heading, unordered list item, ordered list item.

A property in XMLmind XML Editor - Configuration and Deployment configuration element having a "configuration_name markdownMapping" name attribute must be specified in order to map Markdown markup to equivalent XML elements. Syntax:

specifications -> specification [ NEW_LINE specification ]*1

specification -> paragraph_names | mapping

paragraph_names2 -> 'paragraph' S '=' element_name3 [ S element_name ]+

mapping -> markup S '=' S element [ '/' element ]*4

markup -> 'italic' | 'bold' | 'boldItalic' | 'code' | 'strikethrough' |
          'highlight' | 'subscript' |'superscript' | 
          'link' | 'internalLink'5 | 'image' | 
          'heading1' | 'heading2' | 'heading3' | 
          'heading4' |'heading5' | 'heading6' |
          'listItem' | 'orderedListItem' 

element -> element_name [ '[' attribute ']' ]?6

attribute -> attribute_name S '=' S [ '"'|"'" ]? attribute_value [ '"'|"'" ]?

1

Open lines and line starting with '#' are ignored.

2

paragraph_names specifies the name of paragraph elements. DocBook 4 example: "paragraph=para simpara". If specified (which is recommended), heading, unordered list item, ordered list item replacements are performed only inside these paragraph elements.

3

Element and attribute names are specified using the so-called James Clark's notation. Examples: simpara, {http://www.w3.org/1999/xhtml}code, href, xml:space.

4

A Markdown markup may be mapped not only to a single element but also to an element tree. DocBook 4 example: "listItem=itemizedlist[spacing=compact]/listitem/para".

5

internalLink may be used to make a difference between an external link (e.g. "[XMLmind](https://www.xmlmind.com)") and a internal link starting with '#' (e.g. "[Introduction](#intro)"). DocBook 4 example:

link=ulink[url="${href}"]
internalLink=link[linkend="${href.fragment}"]".

6

A Markdown markup may be mapped to an element having one or more attributes.DocBook 4 example: "bold=emphasis[role=bold]".

Some of these attributes may contain substituted variables like ${href}, ${href.fragment} in the above link, internalLink DocBook 4 example.

Markdown markupVariables
Link [link_text](URL "title")
  • ${href} replaced by URL.

  • ${href.fragment} replaced by the fragment found in URL if any.

  • ${title} replaced by title.

Image ![alt_text](URL "title")
  • ${src} replaced by URL.

  • ${alt} replaced by alt_text.

  • ${title} replaced by title.

Note that empty attributes are not added to the element replacing the Markdown markup. XHTML example:

link={http://www.w3.org/1999/xhtml}a[href="${href}" title="${title}"]

"[XMLmind](https://www.xmlmind.com)" is replaced by "<a href="https://www.xmlmind.com">XMLmind</a>". Note that XHTML element a has no title attribute.

Example 6.14. DocBook 4 Markdown mapping
<property name="$c markdownMapping">
  italic=emphasis
  bold=emphasis[role="bold"]
  code=literal
  highlight=emphasis[role="underline"]
  subscript=subscript
  superscript=superscript

  link=ulink[url="${href}"]
  internalLink=link[linkend="${href.fragment}"]
  image=inlinemediaobject/imageobject/imagedata[fileref="${src}"]

  paragraph=para simpara

  heading1=bridgehead[renderas=sect1]
  heading2=bridgehead[renderas=sect2]
  heading3=bridgehead[renderas=sect3]
  heading4=bridgehead[renderas=sect4]
  heading5=bridgehead[renderas=sect5]
  listItem=itemizedlist[spacing=compact]/listitem/para
  orderedListItem=orderedlist[spacing=compact]/listitem/para
</property>
Example 6.15. XHTML Markdown mapping
<property name="$c markdownMapping">
   italic={http://www.w3.org/1999/xhtml}em
   bold={http://www.w3.org/1999/xhtml}strong
   boldItalic={http://www.w3.org/1999/xhtml}strong/¬
{http://www.w3.org/1999/xhtml}em
   code={http://www.w3.org/1999/xhtml}code
   strikethrough={http://www.w3.org/1999/xhtml}del
   highlight={http://www.w3.org/1999/xhtml}mark
   subscript={http://www.w3.org/1999/xhtml}sub
   superscript={http://www.w3.org/1999/xhtml}sup

   link={http://www.w3.org/1999/xhtml}a[href="${href}" title="${title}"]
   image={http://www.w3.org/1999/xhtml}img[src="${src}" alt="${alt}"¬
title="${title}"]

   paragraph={http://www.w3.org/1999/xhtml}p

   heading1={http://www.w3.org/1999/xhtml}h1
   heading2={http://www.w3.org/1999/xhtml}h2
   heading3={http://www.w3.org/1999/xhtml}h3
   heading4={http://www.w3.org/1999/xhtml}h4
   heading5={http://www.w3.org/1999/xhtml}h5
   heading6={http://www.w3.org/1999/xhtml}h6

   listItem={http://www.w3.org/1999/xhtml}ul/¬
{http://www.w3.org/1999/xhtml}li
   orderedListItem={http://www.w3.org/1999/xhtml}ol/¬
{http://www.w3.org/1999/xhtml}li
</property>