public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* XML-ID when converting to markdown
@ 2023-04-05 22:38 hcf
       [not found] ` <941a4fdb-f161-42e5-856b-d98e88db882dn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: hcf @ 2023-04-05 22:38 UTC (permalink / raw)
  To: pandoc-discuss


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

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/941a4fdb-f161-42e5-856b-d98e88db882dn%40googlegroups.com.

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: XML-ID when converting to markdown
       [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>
  0 siblings, 1 reply; 4+ messages in thread
From: Julien Dutant @ 2023-04-06 14:20 UTC (permalink / raw)
  To: pandoc-discuss


[-- 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 --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: XML-ID when converting to markdown
       [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>
  0 siblings, 1 reply; 4+ messages in thread
From: Julien Dutant @ 2023-04-06 14:22 UTC (permalink / raw)
  To: pandoc-discuss


[-- 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 --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: XML-ID when converting to markdown
       [not found]         ` <a7814858-ae37-4788-acd3-6566b3e70bd1n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2023-04-07 13:16           ` hcf
  0 siblings, 0 replies; 4+ messages in thread
From: hcf @ 2023-04-07 13:16 UTC (permalink / raw)
  To: pandoc-discuss


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

Thanks! This works.

torsdag 6. april 2023 kl. 16:22:17 UTC+2 skrev Julien Dutant:

> 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/88b9fb33-d8cf-4221-af8d-22c26c3c5033n%40googlegroups.com.

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-04-07 13:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-05 22:38 XML-ID when converting to markdown 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
     [not found]         ` <a7814858-ae37-4788-acd3-6566b3e70bd1n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2023-04-07 13:16           ` hcf

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