public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
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:20:48 -0700 (PDT)	[thread overview]
Message-ID: <115179cd-21e7-4e29-aea0-add708149ce0n@googlegroups.com> (raw)
In-Reply-To: <941a4fdb-f161-42e5-856b-d98e88db882dn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>


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

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/115179cd-21e7-4e29-aea0-add708149ce0n%40googlegroups.com.

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

  parent reply	other threads:[~2023-04-06 14:20 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 [this message]
     [not found]     ` <115179cd-21e7-4e29-aea0-add708149ce0n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2023-04-06 14:22       ` Julien Dutant
     [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=115179cd-21e7-4e29-aea0-add708149ce0n@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).