From: Julien Dutant <julien.dutant-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: pandoc-discuss <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
Subject: Re: XML-ID when converting to markdown
Date: Thu, 6 Apr 2023 07:22:17 -0700 (PDT) [thread overview]
Message-ID: <a7814858-ae37-4788-acd3-6566b3e70bd1n@googlegroups.com> (raw)
In-Reply-To: <115179cd-21e7-4e29-aea0-add708149ce0n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
[-- Attachment #1.1: Type: text/plain, Size: 2092 bytes --]
Oops, remove the "print(id)" line in the filter script above, it was meant
for debugging.
On Thursday, April 6, 2023 at 3:20:48 PM UTC+1 Julien Dutant wrote:
> This filter will remove all empty Spans with id starting with x. Save as
> "removeXSpans.lua':
>
> function Span(el)
> return #el.content == 0 and el.identifier:match('^x%d') and pandoc.Space()
> or el
> end
>
> And run pandoc with the `-L removeXSpans.lua` option, e.g.
> pandoc -f dockbook sourcefile -t markdown -o outfile.md -L removeXSpans.lua
>
> Result:
> # 1 Introduction
>
> However, this will break any link to #x1-10001. If there are internal
> links in the doc (e.g. from the table of
> content) that you need to preserve, you need a filter that produces
> instead:
> # 1 Introduction {#x1-10001}
>
> Perhaps this will work (it'd help to have a sample docbook source), saved
> as removeXSpans.lua and used as above
>
> function Header(hd)
> local id = ''
> hd.content = hd.content:walk {
> Span = function(el)
> if #el.content == 0 and el.identifier:match('^x%d') then
> id = el.identifier
> return pandoc.Space()
> end
> end
> }
> print(id)
> if id ~= '' then
> hd.identifier = id
> return hd
> end
> end
>
> On Wednesday, April 5, 2023 at 11:38:07 PM UTC+1 hcf wrote:
>
>> I'm converting from DocBook to Markdown.
>>
>> In DocBook there are xml:id tags. When I convert to markdown these are
>> rendered as
>>
>> []{#x1-10001}.
>>
>>
>> A markdown heading look like this when converting from DocBook.
>>
>>
>> # 1[]{#x1-10001}Introduction
>>
>>
>> Is there a way to turn this off?
>>
>>
>> best regards
>>
>> hcf
>>
>
--
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/a7814858-ae37-4788-acd3-6566b3e70bd1n%40googlegroups.com.
[-- Attachment #1.2: Type: text/html, Size: 5028 bytes --]
next prev parent reply other threads:[~2023-04-06 14:22 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-05 22:38 hcf
[not found] ` <941a4fdb-f161-42e5-856b-d98e88db882dn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2023-04-06 14:20 ` Julien Dutant
[not found] ` <115179cd-21e7-4e29-aea0-add708149ce0n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2023-04-06 14:22 ` Julien Dutant [this message]
[not found] ` <a7814858-ae37-4788-acd3-6566b3e70bd1n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2023-04-07 13:16 ` hcf
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=a7814858-ae37-4788-acd3-6566b3e70bd1n@googlegroups.com \
--to=julien.dutant-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).