public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
From: BPJ <melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: pandoc-discuss <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
Subject: syntax-definition for Pandoc's Markdown
Date: Mon, 15 May 2023 10:18:53 +0200	[thread overview]
Message-ID: <CADAJKhBZuAq+ynbxJXwTBpSefk6VY4GAmnFkWGFqf-L++LTEAA@mail.gmail.com> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 2345 bytes --]

This reminds me I did some hacking on an (old) Markdown syntax definition
found on GitHub to at least give some support to Pandoc extensions, e.g.
attributes are highlighted with the item they belong to, spans are
highlighted as dsOthers. It could certainly be made more sophisticated but
I haven't found out how you specify that an item must follow another item.

Should I add it to the GitHub wiki?

Den sön 14 maj 2023 18:44John MacFarlane <fiddlosopher-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> skrev:

> Does your xml file define a context called Parameters?  This looks like a
> problem with your syntax definition
>
> On May 14, 2023, at 4:40 AM, Karl Weber <karl.weber99-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> Hi,
>
> yesterday I upgraded from release 2.11.3.2 to 3.1.2 and ran into some
> incompatibilities. I could fix those related to lua scripts, but I am
> stuck
> with my syntax definition.  (Both releases are the binary distributions
> from
> the pandoc website.)
>
> I have my own KDE-style XML syntax definition file named asshell.xml. In
> my
> global.yaml file it is specifies as
>
> syntax-definition: ../../../asshell.xml
>
> This relative path is correct. OS is opensuse. I use this syntax
> definition as
>
> ~~~~~~{.asshell}
> blabla
> ~~~~~~
>
> The file asshell.xml starts with
>
>  <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE language SYSTEM "language.dtd">
> <language name="asshell" version="1" kateversion="2.3" section="Sources"
> extensions="*.asshell" priority="5" author="KW" license="GPL">
>
> This worked perfectly with releases up to and including 2.11.3.2, but with
> 3.1.2 I get the error message
>
> [WARNING] Could not highlight code block:
>   Unknown syntax or context: ("asshell","Parameters")
>
> Could you please give me some help?
>
> Thanks in advance!
>
> Kind regards
> Karl
>
>

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CADAJKhBZuAq%2BynbxJXwTBpSefk6VY4GAmnFkWGFqf-L%2B%2BLTEAA%40mail.gmail.com.

[-- Attachment #1.2: Type: text/html, Size: 3484 bytes --]

[-- Attachment #2: pandoc.xml --]
[-- Type: text/xml, Size: 10292 bytes --]

<?xml version="1.0" encoding="UTF-8"?>
<!--
	Kate syntax highlight filter for Markdown/MultiMarkdown documents.

	Copyright 2008 Darrin Yeager. http://www.dyeager.org/
	Dual-Licensed under both GPL and BSD licenses.

	Extended 2009 Claes Holmerson. http://github.com/claes/kate-markdown/

Extended 2019-2023 by Benct Philip Jonsson bpjonsson@gmail.com to provide some support for Pandoc's http://pandoc.org flavor of Markdown.
-->


<!-- the [^\s]{1} is in the regex to avoid interfering with bullet list which
	  starts "* item". Thus emphasis/strong MUST be formed like *words here*
	  with the asterisks next to the beginning of the first word.

	  Match space or newline, followed by "*", followed by one non-space,
	  followed by anything non-asterisk, followed by "*", followed by
	  space, end-of-sentence punctuation, or the end of the line.
-->

<!DOCTYPE language SYSTEM "language.dtd"
			 [
             <!ENTITY afteremphregex "(?=\s|\.|,|;|:|\-|\?|$)">
             <!ENTITY insideemphregex "([^_]+|[^\s_]_[^\s_])+">
             <!ENTITY bracketregex "\[([^\[\]\^]+|\[([^\[\]\^]+|\[([^\[\]\^]+|\[([^\[\]\^]+|\[([^\[\]\^]+)*\])*\])*\])*\])*\]">
             <!ENTITY attrregex '\{([^\{\}\"\&#x27;]+|\"([^\"\\]+|\\.)*\"|\&#x27;([^\&#x27;\\]+|\\.)*\&#x27;)*\}'> <!-- pandoc style -->
             <!ENTITY strongemphasisregex "(_{3}((?!_{3})[\s\S])+_{3}|\*{3}((?!\*{3})[\s\S])+\*{3})">
             <!ENTITY strongregex "(_{2}((?!_{2})[\s\S])+_{2}|\*{2}((?!\*{2})[\s\S])+\*{2})">
             <!ENTITY emphasisregex "(\s|^)(_{1}[^\s_]{1}&insideemphregex;_{1}|\*{1}[^\*]+\*{1})&afteremphregex;">
			 <!ENTITY reflinkregex '&bracketregex;\s*\[[^\[\]]*\]\s*(\s+\"[^\"]*\"){0,1}'>
			 <!ENTITY reflinktargetregex '&bracketregex;\:\s+[^\s]+(\s+\"[^\"]*\"){0,1}'>
			 <!ENTITY fnoteregex "\[\^[^\[\]]+\]">
			 <!ENTITY fnotetargetregex "^\s*\[\^[^\[\]]+\]\:">
             <!ENTITY inlinelinkregex '&bracketregex;\s*\([^\(\)]*\)&attrregex;?'> 
             <!ENTITY inlineimageregex '\!&bracketregex;\([^\(\)]*\)&attrregex;?'>
			 <!ENTITY refimageregex '\!&bracketregex;\[[^\[]*\]'>
			 <!ENTITY autolinkregex '&lt;(https?|ftp):[^\"&gt;\s]+&gt;'>
			 <!ENTITY mailtolinkregex '&lt;(?:mailto:)?([-.\w]+\@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)&gt;'>
			 <!ENTITY rulerregex '^\s*([\*\-_]\s?){3,}\s*$'>
			 <!-- two spaces at end of line generates linebreak -->
			 <!ENTITY linebreakregex "(  $|\\$)">
        <!-- pandoc additions -->
             <!ENTITY blockattrregex "\s*(&attrregex;|[A-Za-z]\w*)">
             <!ENTITY markregex "[=]{2}((?![=]{2}).)+[=]{2}">
             <!ENTITY strikeoutregex "[~]{2}((?![~]{2}).)+[~]{2}"> <!-- pandoc style -->
             <!ENTITY subscriptregex "[~]{1}([^\~\s\\]+|\\.)+[~]{1}"> <!-- pandoc style -->
             <!ENTITY superscriptregex "[\^]{1}([^\^\s\\]+|\\.)+[\^]{1}"> <!-- pandoc style -->
             <!ENTITY spanregex '&bracketregex;\s*&attrregex;'> <!-- pandoc style -->
             <!ENTITY divregex "[:]{3,}&blockattrregex;?"> <!-- pandoc style -->
             <!ENTITY numregex "([\d]+|[ivxlcdmIVXLCDM]+|[a-zA-Z])"> <!-- pandoc style -->
             <!ENTITY ordlistregex "(\(?&numregex;\)|&numregex;\.)"> <!-- pandoc style -->
]>

<language name="PandocMarkdown" version="1.2" section="Markup"
		extensions="*.text;*.md;*.mmd;*.mkd;*.markdown" priority="15"
		author="Darrin Yeager, Claes Holmerson"
		license="GPL,BSD" >

	<highlighting>

		<contexts>
			<context attribute="Normal Text" lineEndContext="#stay" name="Normal Text" >
				<DetectChar context="blockquote" char="&gt;" column="0"/>
				<RegExpr attribute="heading" String="^[#]+\s.*[#]?$" />
				<RegExpr attribute="heading" String="^==+$" />
				<RegExpr attribute="heading" String="^--+$" />
				<RegExpr attribute="strongemphasis" String="&strongemphasisregex;" />
				<RegExpr attribute="ruler" String="&rulerregex;" />
				<RegExpr attribute="strong" String="&strongregex;" />
				<RegExpr attribute="emphasis" String="&emphasisregex;" />
				<RegExpr attribute="code" String="^([\s]{4,}|\t+).*$" />
				<RegExpr context="bullet" String="^\s*[\*\+\-]\s" />
				<RegExpr context="ordlist" String="^\s*&ordlistregex;\s" />
				<RegExpr attribute="div" String="&divregex;" />
				<!-- <RegExpr attribute="meta" String="^(Title|Author|Date|Copyright|Revision|CSS|LaTeX\ XSLT|Categories|Tags|BaseName|Excerpt):(.*)+$" /> -->
				<IncludeRules context="inc" />

				<!-- GitHub highlighted code -->
				<RegExpr attribute="code" context="highlightnone" String="^\s*```+&blockattrregex;?" beginRegion="code" />
				<!-- Pandoc mdetadata -->
				<RegExpr attribute="meta" context="highlightmeta" String="^---\s*$" />
			</context>

			<context attribute="blockquote" lineEndContext="#pop" name="blockquote">
				<RegExpr attribute="bq-strong" String="&strongregex;" />
				<RegExpr attribute="bq-emphasis" String="&emphasisregex;" />
				<IncludeRules context="inc" />
			</context>

			<context attribute="bullet" lineEndContext="#pop" name="bullet" >
				<RegExpr attribute="bl-strong" String="&strongregex;" />
				<RegExpr attribute="bl-emphasis" String="&emphasisregex;" />
				<IncludeRules context="inc" />
			</context>

			<context attribute="ordlist" lineEndContext="#pop" name="ordlist" >
				<RegExpr attribute="ol-strong" String="&strongregex;" />
				<RegExpr attribute="ol-emphasis" String="&emphasisregex;" />
				<IncludeRules context="inc" />
			</context>

			<context attribute="comment" lineEndContext="#stay" name="comment" >
				<RegExpr String="--&gt;" attribute="comment" context="#pop" endRegion="comment"/>
			</context>

			<context attribute="common" name="inc" lineEndContext="#stay" >
				<RegExpr attribute="code" String="(`+)((?!\1).)+\1(&attrregex;)?" />
				<RegExpr context="comment" String="&lt;!--" beginRegion="comment" />
				<RegExpr attribute="reflink" String="&reflinkregex;" />
				<RegExpr attribute="fnote" String="&fnoteregex;" />
				<RegExpr attribute="fnotetarget" String="&fnotetargetregex;" />
				<RegExpr attribute="span" String="&spanregex;"/>
				<RegExpr attribute="inlinelink" String="&inlinelinkregex;"/>
				<RegExpr attribute="reflinktarget" String="&reflinktargetregex;"/>
				<RegExpr attribute="inlineimage" String="&inlineimageregex;"/>
				<RegExpr attribute="refimage" String="&refimageregex;"/>
				<RegExpr attribute="autolink" String="&autolinkregex;"/>
				<RegExpr attribute="mailtolink" String="&mailtolinkregex;"/>
				<RegExpr attribute="mark" minimal="true" String="&markregex;"/>
				<RegExpr attribute="strikeout" minimal="true" String="&strikeoutregex;"/>
				<RegExpr attribute="subscript" minimal="true" String="&subscriptregex;"/>
				<RegExpr attribute="superscript" minimal="true" String="&superscriptregex;"/>
				<RegExpr attribute="linebreak" minimal="true" String="&linebreakregex;"/>
			</context>

			<!-- GitHub highlighted code -->

			<context attribute="Normal Text" name="highlightnone" lineEndContext="#stay" >
				<IncludeRules context="inccode" />
			</context>

			<context attribute="common" name="inccode" lineEndContext="#stay" >
				<RegExpr attribute="code" context="#pop" String="^```+\s*$" endRegion="code" />
			</context>

            <!-- Pandoc mdetadata -->

			<context attribute="Normal Text" name="highlightmeta" lineEndContext="#stay" >
				<RegExpr attribute="meta" context="#pop" String="^---$" />
				<IncludeRules context="##YAML" includeAttrib="true" />
			</context>

		</contexts>

		<itemDatas>
			<itemData name="Normal Text"     defStyleNum="dsNormal" />
			<itemData name="common"          defStyleNum="dsNormal" />
			<itemData name="strongemphasis"  defStyleNum="dsString" italic="true" bold="true"/>
			<itemData name="emphasis"        defStyleNum="dsString" italic="true" />
			<itemData name="strong"          defStyleNum="dsString" bold="true" />
			<itemData name="ruler"           defStyleNum="dsConstant" bold="true" />
			<itemData name="mark"       defStyleNum="dsString" underline="true" />
			<itemData name="strikeout"       defStyleNum="dsString" strikeOut="true" />
			<itemData name="subscript"       defStyleNum="dsString" />
			<itemData name="superscript"     defStyleNum="dsString" />
			<itemData name="linebreak"       defStyleNum="dsOperator" underline="true" color="#999999"/>
			<itemData name="heading"         defStyleNum="dsFunction" bold="true" />
			<itemData name="blockquote"      defStyleNum="dsDocumentation" />
			<itemData name="bq-emphasis"     defStyleNum="dsDocumentation" italic="true" />
			<itemData name="bq-strong"       defStyleNum="dsDocumentation" bold="true" />
			<itemData name="bullet"          defStyleNum="dsFloat" />
			<itemData name="bl-emphasis"     defStyleNum="dsFloat" italic="true" />
			<itemData name="bl-strong"       defStyleNum="dsFloat" bold="true" />
			<itemData name="ordlist"         defStyleNum="dsFloat" />
			<itemData name="ol-emphasis"     defStyleNum="dsFloat" italic="true" />
			<itemData name="ol-strong"       defStyleNum="dsFloat" bold="true" />
			<itemData name="comment"         defStyleNum="dsComment" />
			<itemData name="code"            defStyleNum="dsVerbatimString" />
			<itemData name="reflink"         defStyleNum="dsControlFlow" underline="true" />
			<itemData name="span"            defStyleNum="dsOthers" underline="true" />
			<itemData name="div"             defStyleNum="dsOthers" underline="true" />
			<itemData name="inlinelink"      defStyleNum="dsControlFlow" underline="true" />
			<itemData name="autolink"        defStyleNum="dsControlFlow" underline="true" />
			<itemData name="mailtolink"      defStyleNum="dsControlFlow" underline="true" />
			<itemData name="fnote"           defStyleNum="dsVariable" italic="true" />
			<itemData name="fnotetarget"     defStyleNum="dsVariable" italic="true" />
			<itemData name="meta"            defStyleNum="dsPreprocessor" />
			<itemData name="reflinktarget"   defStyleNum="dsControlFlow" italic="false" bold="false" />
			<itemData name="inlineimage"     defStyleNum="dsControlFlow" italic="false" bold="false" />
			<itemData name="refimage"        defStyleNum="dsControlFlow" italic="false" bold="false" />
		</itemDatas>

	</highlighting>

	<general>
		<comments>
			<comment name="multiLine" start="&lt;!--" end="--&gt;" region="comment" />
		</comments>
	</general>

</language>

                 reply	other threads:[~2023-05-15  8:18 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CADAJKhBZuAq+ynbxJXwTBpSefk6VY4GAmnFkWGFqf-L++LTEAA@mail.gmail.com \
    --to=melroch-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).