public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* Markdown syntax can't handle BibLaTeX formatting
@ 2017-11-01 13:25 distantflag
       [not found] ` <90e14ff2-6cec-4dfe-9236-0998cf317b6c-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 14+ messages in thread
From: distantflag @ 2017-11-01 13:25 UTC (permalink / raw)
  To: pandoc-discuss


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

I have an issue where the Markdown syntax for referring to bibliographical 
sources can't treat direct links to the entries in an BibLaTeX file.

For instance, the BibLaTeX file looks like this:

@online{statute._2014/foo:bar_title_????,
title = {Title},
author = {{Statute. 2014/Foo:Bar}},
langid = {swedish}
}

@report{author_report:_2014,
location = {Foobar},
title = {Report: Foo (Bar)},
url = {http://foo.bar},
author = {{Author}},
urldate = {2017-11-01},
date = {2014}
}

The Markdown formatting for referring to this would be

[@statute._2014/foo:bar_title_????]

and

[@author_report:_2014]

However, the question marks and the colon messes up the syntax formatting 
and the sources cannot be converted to plain text using pandoc.

What can be done about this? 

-- 
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 post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/90e14ff2-6cec-4dfe-9236-0998cf317b6c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

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

* Re: Markdown syntax can't handle BibLaTeX formatting
       [not found] ` <90e14ff2-6cec-4dfe-9236-0998cf317b6c-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2017-11-01 16:40   ` John MACFARLANE
  2017-11-01 20:40   ` Albert Krewinkel
  1 sibling, 0 replies; 14+ messages in thread
From: John MACFARLANE @ 2017-11-01 16:40 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

Short answer: you need to change your bibtex keys if you
want to use them with pandoc.

See the manual under Citations:

> Citations go inside square brackets and are separated by
> semicolons.  Each citation must have a key, composed of '@'
> + the citation identifier from the database, and may
> optionally have a prefix, a locator, and a suffix.  The
> citation key must begin with a letter, digit, or `_`, and
> may contain alphanumerics, `_`, and internal punctuation
> characters (`:.#$%&-+?<>~/`).

Question marks are possible, but only if they are
"internal"; you can't have a question mark at the
end of the citation key.  Why not?  Well, consider:

    What do you think about the theory of @smith2000?

Here pandoc has to decide whether the ? is part of the
citation key or punctuation.  The way we resolve this
is by forbidding citation keys to end with punctuation.


+++ distantflag [Nov 01 17 06:25 ]:
>   I have an issue where the Markdown syntax for referring to
>   bibliographical sources can't treat direct links to the entries in an
>   BibLaTeX file.
>   For instance, the BibLaTeX file looks like this:
>   @online{statute._2014/foo:bar_title_????,
>   title = {Title},
>   author = {{Statute. 2014/Foo:Bar}},
>   langid = {swedish}
>   }
>   @report{author_report:_2014,
>   location = {Foobar},
>   title = {Report: Foo (Bar)},
>   url = {http://foo.bar},
>   author = {{Author}},
>   urldate = {2017-11-01},
>   date = {2014}
>   }
>   The Markdown formatting for referring to this would be
>   [@statute._2014/foo:bar_title_????]
>   and
>   [@author_report:_2014]
>   However, the question marks and the colon messes up the syntax
>   formatting and the sources cannot be converted to plain text using
>   pandoc.
>   What can be done about this?
>
>   --
>   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 [1]pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>   To post to this group, send email to
>   [2]pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>   To view this discussion on the web visit
>   [3]https://groups.google.com/d/msgid/pandoc-discuss/90e14ff2-6cec-4dfe-
>   9236-0998cf317b6c%40googlegroups.com.
>   For more options, visit [4]https://groups.google.com/d/optout.
>
>References
>
>   1. mailto:pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
>   2. mailto:pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
>   3. https://groups.google.com/d/msgid/pandoc-discuss/90e14ff2-6cec-4dfe-9236-0998cf317b6c-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org?utm_medium=email&utm_source=footer
>   4. https://groups.google.com/d/optout


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

* Re: Markdown syntax can't handle BibLaTeX formatting
       [not found] ` <90e14ff2-6cec-4dfe-9236-0998cf317b6c-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  2017-11-01 16:40   ` John MACFARLANE
@ 2017-11-01 20:40   ` Albert Krewinkel
       [not found]     ` <87tvyd4trv.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
  1 sibling, 1 reply; 14+ messages in thread
From: Albert Krewinkel @ 2017-11-01 20:40 UTC (permalink / raw)
  To: distantflag; +Cc: pandoc-discuss

If, for some reason, the bib keys cannot be changed, the combination of
spans and filters might come in handy:

Write citations as a markdown span

    [statute._2014/foo:bar_title_????]{.cite}

and use a filter like the following to convert the span into a citation.

    function Span(elem)
      if elem.classes[1] == "cite" then
        local citeId = elem.content[1].text
        local citeMode = pandoc.AuthorInText
        local citation = pandoc.Citation(citeId, citeMode)
        return pandoc.Cite(elem.content, {citation})
      end
    end
    
It is not a pretty solution, but you might find it useful regardless.


distantflag <eksbjo-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:

> I have an issue where the Markdown syntax for referring to bibliographical sources can't treat direct links to the entries in an BibLaTeX file.
>
> For instance, the BibLaTeX file looks like this:
>
> @online{statute._2014/foo:bar_title_????,
> title = {Title},
> author = {{Statute. 2014/Foo:Bar}},
> langid = {swedish}
> }
>
> @report{author_report:_2014,
> location = {Foobar},
> title = {Report: Foo (Bar)},
> url = {http://foo.bar},
> author = {{Author}},
> urldate = {2017-11-01},
> date = {2014}
> }
>
> The Markdown formatting for referring to this would be
>
> [@statute._2014/foo:bar_title_????]
>
> and
>
> [@author_report:_2014]
>
> However, the question marks and the colon messes up the syntax formatting and the sources cannot be converted to plain text using pandoc.
>
> What can be done about this? 

-- 
Albert Krewinkel
GPG: 8eed e3e2 e8c5 6f18 81fe  e836 388d c0b2 1f63 1124


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

* Re: Markdown syntax can't handle BibLaTeX formatting
       [not found]     ` <87tvyd4trv.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
@ 2017-11-02  7:39       ` distantflag
       [not found]         ` <cfc702fb-7389-4b78-88c8-0ec235ffa481-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 14+ messages in thread
From: distantflag @ 2017-11-02  7:39 UTC (permalink / raw)
  To: pandoc-discuss


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

Hello,

Thanks for your replies. I could of course change the bibkeys. But since I 
am generating them through export from Zotero I would like to do so now and 
again when adding citations to a text, not having to edit each and every 
faulty bibkey each time this export process is done.

Albert Krewinkel: This script seems handy. Where do I place it? As a file 
by itself or inside the Markdown file? I tried the latter but I didn't seem 
to get it right.

Den onsdag 1 november 2017 kl. 21:41:48 UTC+1 skrev Albert Krewinkel:
>
> If, for some reason, the bib keys cannot be changed, the combination of 
> spans and filters might come in handy: 
>
> Write citations as a markdown span 
>
>     [statute._2014/foo:bar_title_????]{.cite} 
>
> and use a filter like the following to convert the span into a citation. 
>
>     function Span(elem) 
>       if elem.classes[1] == "cite" then 
>         local citeId = elem.content[1].text 
>         local citeMode = pandoc.AuthorInText 
>         local citation = pandoc.Citation(citeId, citeMode) 
>         return pandoc.Cite(elem.content, {citation}) 
>       end 
>     end 
>     
> It is not a pretty solution, but you might find it useful regardless. 
>
>
> distantflag <eks...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <javascript:>> writes: 
>
> > I have an issue where the Markdown syntax for referring to 
> bibliographical sources can't treat direct links to the entries in an 
> BibLaTeX file. 
> > 
> > For instance, the BibLaTeX file looks like this: 
> > 
> > @online{statute._2014/foo:bar_title_????, 
> > title = {Title}, 
> > author = {{Statute. 2014/Foo:Bar}}, 
> > langid = {swedish} 
> > } 
> > 
> > @report{author_report:_2014, 
> > location = {Foobar}, 
> > title = {Report: Foo (Bar)}, 
> > url = {http://foo.bar}, 
> > author = {{Author}}, 
> > urldate = {2017-11-01}, 
> > date = {2014} 
> > } 
> > 
> > The Markdown formatting for referring to this would be 
> > 
> > [@statute._2014/foo:bar_title_????] 
> > 
> > and 
> > 
> > [@author_report:_2014] 
> > 
> > However, the question marks and the colon messes up the syntax 
> formatting and the sources cannot be converted to plain text using pandoc. 
> > 
> > What can be done about this? 
>
> -- 
> Albert Krewinkel 
> GPG: 8eed e3e2 e8c5 6f18 81fe  e836 388d c0b2 1f63 1124 
>

-- 
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 post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/cfc702fb-7389-4b78-88c8-0ec235ffa481%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

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

* Re: Markdown syntax can't handle BibLaTeX formatting
       [not found]         ` <cfc702fb-7389-4b78-88c8-0ec235ffa481-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2017-11-02  7:53           ` Björn Ekström
       [not found]             ` <5fdd83a6-e681-42bf-91b5-1216e605f76b-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  2017-11-02 20:02           ` Albert Krewinkel
  1 sibling, 1 reply; 14+ messages in thread
From: Björn Ekström @ 2017-11-02  7:53 UTC (permalink / raw)
  To: pandoc-discuss


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

Also, why wouldn't 

What do you think about the theory of [@smith2000?]?


be valid formatting? 

 


Den torsdag 2 november 2017 kl. 08:39:29 UTC+1 skrev Björn Ekström:
>
> Hello,
>
> Thanks for your replies. I could of course change the bibkeys. But since I 
> am generating them through export from Zotero I would like to do so now and 
> again when adding citations to a text, not having to edit each and every 
> faulty bibkey each time this export process is done.
>
> Albert Krewinkel: This script seems handy. Where do I place it? As a file 
> by itself or inside the Markdown file? I tried the latter but I didn't seem 
> to get it right.
>
> Den onsdag 1 november 2017 kl. 21:41:48 UTC+1 skrev Albert Krewinkel:
>>
>> If, for some reason, the bib keys cannot be changed, the combination of 
>> spans and filters might come in handy: 
>>
>> Write citations as a markdown span 
>>
>>     [statute._2014/foo:bar_title_????]{.cite} 
>>
>> and use a filter like the following to convert the span into a citation. 
>>
>>     function Span(elem) 
>>       if elem.classes[1] == "cite" then 
>>         local citeId = elem.content[1].text 
>>         local citeMode = pandoc.AuthorInText 
>>         local citation = pandoc.Citation(citeId, citeMode) 
>>         return pandoc.Cite(elem.content, {citation}) 
>>       end 
>>     end 
>>     
>> It is not a pretty solution, but you might find it useful regardless. 
>>
>>
>> distantflag <eks...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes: 
>>
>> > I have an issue where the Markdown syntax for referring to 
>> bibliographical sources can't treat direct links to the entries in an 
>> BibLaTeX file. 
>> > 
>> > For instance, the BibLaTeX file looks like this: 
>> > 
>> > @online{statute._2014/foo:bar_title_????, 
>> > title = {Title}, 
>> > author = {{Statute. 2014/Foo:Bar}}, 
>> > langid = {swedish} 
>> > } 
>> > 
>> > @report{author_report:_2014, 
>> > location = {Foobar}, 
>> > title = {Report: Foo (Bar)}, 
>> > url = {http://foo.bar}, 
>> > author = {{Author}}, 
>> > urldate = {2017-11-01}, 
>> > date = {2014} 
>> > } 
>> > 
>> > The Markdown formatting for referring to this would be 
>> > 
>> > [@statute._2014/foo:bar_title_????] 
>> > 
>> > and 
>> > 
>> > [@author_report:_2014] 
>> > 
>> > However, the question marks and the colon messes up the syntax 
>> formatting and the sources cannot be converted to plain text using pandoc. 
>> > 
>> > What can be done about this? 
>>
>> -- 
>> Albert Krewinkel 
>> GPG: 8eed e3e2 e8c5 6f18 81fe  e836 388d c0b2 1f63 1124 
>>
>

-- 
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 post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/5fdd83a6-e681-42bf-91b5-1216e605f76b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

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

* Re: Markdown syntax can't handle BibLaTeX formatting
       [not found]             ` <5fdd83a6-e681-42bf-91b5-1216e605f76b-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2017-11-02 19:22               ` John MACFARLANE
  0 siblings, 0 replies; 14+ messages in thread
From: John MACFARLANE @ 2017-11-02 19:22 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

+++ Björn Ekström [Nov 02 17 00:53 ]:
>   Also, why wouldn't
>
>   What do you think about the theory of [@smith2000?]?
>
>   be valid formatting?

That creates no ambiguity, but in pandoc you can also have
bare citation keys (author-in-text citations).

We use the same rules and parser for citation keys whether
they occur in or out of brackets.

-- 
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 post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/20171102192229.GB18456%40protagoras.
For more options, visit https://groups.google.com/d/optout.


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

* Re: Markdown syntax can't handle BibLaTeX formatting
       [not found]         ` <cfc702fb-7389-4b78-88c8-0ec235ffa481-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  2017-11-02  7:53           ` Björn Ekström
@ 2017-11-02 20:02           ` Albert Krewinkel
       [not found]             ` <87po904ffv.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
  1 sibling, 1 reply; 14+ messages in thread
From: Albert Krewinkel @ 2017-11-02 20:02 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

distantflag <eksbjo-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:

> Thanks for your replies. I could of course change the bibkeys. But
> since I am generating them through export from Zotero I would like to
> do so now and again when adding citations to a text, not having to
> edit each and every faulty bibkey each time this export process is
> done.

Another option could be to write a small script which replaces all
question marks with underscored or zeros in your bibtex keys. The script
could then be run each time the bib file is regenerated by Zotero. The
[bibtexparser] python library seems like a good fit for this, but a perl
or awk command might work as well.

[bibtexparser]: https://bibtexparser.readthedocs.io

> Albert Krewinkel: This script seems handy. Where do I place it?

The script is best placed in a separate file, e.g. `citation-spans.lua`.
Pandoc must then be invoked with the additional parameter
`--lua-script=citation-spans.lua`.


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

* Re: Markdown syntax can't handle BibLaTeX formatting
       [not found]             ` <87po904ffv.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
@ 2017-11-02 20:22               ` John MACFARLANE
  2017-11-02 21:22                 ` Albert Krewinkel
  0 siblings, 1 reply; 14+ messages in thread
From: John MACFARLANE @ 2017-11-02 20:22 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

Another approach could be to use pandoc-citeproc -y to
convert the bibtex to pandoc markdown YAML and include
this on the command line instead of specifying the bibtex
file.  A filter could then be added that acts before
pandoc-citeproc and changes the citation ids in the metadata.

+++ Albert Krewinkel [Nov 02 17 21:02 ]:
>distantflag <eksbjo-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:
>
>> Thanks for your replies. I could of course change the bibkeys. But
>> since I am generating them through export from Zotero I would like to
>> do so now and again when adding citations to a text, not having to
>> edit each and every faulty bibkey each time this export process is
>> done.
>
>Another option could be to write a small script which replaces all
>question marks with underscored or zeros in your bibtex keys. The script
>could then be run each time the bib file is regenerated by Zotero. The
>[bibtexparser] python library seems like a good fit for this, but a perl
>or awk command might work as well.
>
>[bibtexparser]: https://bibtexparser.readthedocs.io
>
>> Albert Krewinkel: This script seems handy. Where do I place it?
>
>The script is best placed in a separate file, e.g. `citation-spans.lua`.
>Pandoc must then be invoked with the additional parameter
>`--lua-script=citation-spans.lua`.
>
>-- 
>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 post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/87po904ffv.fsf%40zeitkraut.de.
>For more options, visit https://groups.google.com/d/optout.


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

* Re: Markdown syntax can't handle BibLaTeX formatting
  2017-11-02 20:22               ` John MACFARLANE
@ 2017-11-02 21:22                 ` Albert Krewinkel
       [not found]                   ` <87k1z84bpy.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
  0 siblings, 1 reply; 14+ messages in thread
From: Albert Krewinkel @ 2017-11-02 21:22 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

John MACFARLANE <jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org> writes:

> Another approach could be to use pandoc-citeproc -y to
> convert the bibtex to pandoc markdown YAML and include
> this on the command line instead of specifying the bibtex
> file.  A filter could then be added that acts before
> pandoc-citeproc and changes the citation ids in the metadata.

This is such a beautiful solution that I couldn't resist to code up a
proof-of-concept.  The path to the bibtex file must be stored in the
*bibliography* yaml field:

    ```
    bibliography: path/to/bibliography.bib
    ...

fix-bibkeys.lua:

    function references_from_bibfile (filename)
      local yaml = io.popen('pandoc-citeproc -y ' .. filename):read("*a")
      return pandoc.read(yaml).meta.references
    end

    function Meta(meta)
      local bibfile = meta.bibliography[1].text
      local references = references_from_bibfile(bibfile)
      -- modify keys, replace ???? with 0000
      for k, v in pairs(references) do
        references[k].id = v.id[1].text:gsub("%?%?%?%?", "0000")
      end
      meta.references = references
      return meta
   end

Run with

    pandoc --lua-filter=fix-bibkeys.lua --filter=pandoc-citeproc …

> +++ Albert Krewinkel [Nov 02 17 21:02 ]:
>>distantflag <eksbjo-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:
>>
>>> Thanks for your replies. I could of course change the bibkeys. But
>>> since I am generating them through export from Zotero I would like to
>>> do so now and again when adding citations to a text, not having to
>>> edit each and every faulty bibkey each time this export process is
>>> done.
>>
>>Another option could be to write a small script which replaces all
>>question marks with underscored or zeros in your bibtex keys. The script
>>could then be run each time the bib file is regenerated by Zotero. The
>>[bibtexparser] python library seems like a good fit for this, but a perl
>>or awk command might work as well.
>>
>>[bibtexparser]: https://bibtexparser.readthedocs.io
>>
>>> Albert Krewinkel: This script seems handy. Where do I place it?
>>
>>The script is best placed in a separate file, e.g. `citation-spans.lua`.
>>Pandoc must then be invoked with the additional parameter
>>`--lua-script=citation-spans.lua`.
>>
>> -- 
>>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 post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>>To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/87po904ffv.fsf%40zeitkraut.de.
>>For more options, visit https://groups.google.com/d/optout.

-- 
Albert Krewinkel
GPG: 8eed e3e2 e8c5 6f18 81fe  e836 388d c0b2 1f63 1124

-- 
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 post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/87k1z84bpy.fsf%40zeitkraut.de.
For more options, visit https://groups.google.com/d/optout.


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

* Re: Markdown syntax can't handle BibLaTeX formatting
       [not found]                   ` <87k1z84bpy.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
@ 2017-11-02 22:19                     ` John MACFARLANE
  2017-11-03  9:37                       ` Björn Ekström
  0 siblings, 1 reply; 14+ messages in thread
From: John MACFARLANE @ 2017-11-02 22:19 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

Nice!  I hadn't even thought of having the lua filter
do the whole job.

+++ Albert Krewinkel [Nov 02 17 22:22 ]:
>This is such a beautiful solution that I couldn't resist to code up a
>proof-of-concept.  The path to the bibtex file must be stored in the
>*bibliography* yaml field:
>
>    ```
>    bibliography: path/to/bibliography.bib
>    ...
>
>fix-bibkeys.lua:
>
>    function references_from_bibfile (filename)
>      local yaml = io.popen('pandoc-citeproc -y ' .. filename):read("*a")
>      return pandoc.read(yaml).meta.references
>    end
>
>    function Meta(meta)
>      local bibfile = meta.bibliography[1].text
>      local references = references_from_bibfile(bibfile)
>      -- modify keys, replace ???? with 0000
>      for k, v in pairs(references) do
>        references[k].id = v.id[1].text:gsub("%?%?%?%?", "0000")
>      end
>      meta.references = references
>      return meta
>   end
>
>Run with
>
>    pandoc --lua-filter=fix-bibkeys.lua --filter=pandoc-citeproc …

-- 
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 post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/20171102221945.GE27752%40protagoras.
For more options, visit https://groups.google.com/d/optout.


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

* Re: Markdown syntax can't handle BibLaTeX formatting
  2017-11-02 22:19                     ` John MACFARLANE
@ 2017-11-03  9:37                       ` Björn Ekström
       [not found]                         ` <1de89ee9-9064-4020-8419-4bcf7755cf9b-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 14+ messages in thread
From: Björn Ekström @ 2017-11-03  9:37 UTC (permalink / raw)
  To: pandoc-discuss


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

Hm, okay. Thanks. Although, both --lua-script and -lua-filter= gives

pandoc.exe: unrecognized option `--lua-[...]'


Den torsdag 2 november 2017 kl. 23:19:29 UTC+1 skrev John MacFarlane:
>
> Nice!  I hadn't even thought of having the lua filter 
> do the whole job. 
>
> +++ Albert Krewinkel [Nov 02 17 22:22 ]: 
> >This is such a beautiful solution that I couldn't resist to code up a 
> >proof-of-concept.  The path to the bibtex file must be stored in the 
> >*bibliography* yaml field: 
> > 
> >    ``` 
> >    bibliography: path/to/bibliography.bib 
> >    ... 
> > 
> >fix-bibkeys.lua: 
> > 
> >    function references_from_bibfile (filename) 
> >      local yaml = io.popen('pandoc-citeproc -y ' .. filename):read("*a") 
> >      return pandoc.read(yaml).meta.references 
> >    end 
> > 
> >    function Meta(meta) 
> >      local bibfile = meta.bibliography[1].text 
> >      local references = references_from_bibfile(bibfile) 
> >      -- modify keys, replace ???? with 0000 
> >      for k, v in pairs(references) do 
> >        references[k].id = v.id[1].text:gsub("%?%?%?%?", "0000") 
> >      end 
> >      meta.references = references 
> >      return meta 
> >   end 
> > 
> >Run with 
> > 
> >    pandoc --lua-filter=fix-bibkeys.lua --filter=pandoc-citeproc … 
>

-- 
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 post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/1de89ee9-9064-4020-8419-4bcf7755cf9b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

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

* Re: Markdown syntax can't handle BibLaTeX formatting
       [not found]                         ` <1de89ee9-9064-4020-8419-4bcf7755cf9b-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2017-11-03  9:56                           ` Björn Ekström
       [not found]                             ` <219efc35-d812-4b40-addd-adaed55955d8-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 14+ messages in thread
From: Björn Ekström @ 2017-11-03  9:56 UTC (permalink / raw)
  To: pandoc-discuss


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

Never mind, I installed the latest pandoc and got it to work.

So thanks for all your help. Now I just need to figure out how to another 
filter which removes the colon in this bibkey title

[@organization_endreport:_2016]


since the colon (which is part of the title) creates a syntax error with 
the following underscore.

Den fredag 3 november 2017 kl. 10:37:42 UTC+1 skrev Björn Ekström:
>
> Hm, okay. Thanks. Although, both --lua-script and -lua-filter= gives
>
> pandoc.exe: unrecognized option `--lua-[...]'
>
>
> Den torsdag 2 november 2017 kl. 23:19:29 UTC+1 skrev John MacFarlane:
>>
>> Nice!  I hadn't even thought of having the lua filter 
>> do the whole job. 
>>
>> +++ Albert Krewinkel [Nov 02 17 22:22 ]: 
>> >This is such a beautiful solution that I couldn't resist to code up a 
>> >proof-of-concept.  The path to the bibtex file must be stored in the 
>> >*bibliography* yaml field: 
>> > 
>> >    ``` 
>> >    bibliography: path/to/bibliography.bib 
>> >    ... 
>> > 
>> >fix-bibkeys.lua: 
>> > 
>> >    function references_from_bibfile (filename) 
>> >      local yaml = io.popen('pandoc-citeproc -y ' .. 
>> filename):read("*a") 
>> >      return pandoc.read(yaml).meta.references 
>> >    end 
>> > 
>> >    function Meta(meta) 
>> >      local bibfile = meta.bibliography[1].text 
>> >      local references = references_from_bibfile(bibfile) 
>> >      -- modify keys, replace ???? with 0000 
>> >      for k, v in pairs(references) do 
>> >        references[k].id = v.id[1].text:gsub("%?%?%?%?", "0000") 
>> >      end 
>> >      meta.references = references 
>> >      return meta 
>> >   end 
>> > 
>> >Run with 
>> > 
>> >    pandoc --lua-filter=fix-bibkeys.lua --filter=pandoc-citeproc … 
>>
>

-- 
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 post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/219efc35-d812-4b40-addd-adaed55955d8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

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

* Re: Markdown syntax can't handle BibLaTeX formatting
       [not found]                             ` <219efc35-d812-4b40-addd-adaed55955d8-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2017-11-03 18:51                               ` Albert Krewinkel
       [not found]                                 ` <87bmkj42mv.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
  0 siblings, 1 reply; 14+ messages in thread
From: Albert Krewinkel @ 2017-11-03 18:51 UTC (permalink / raw)
  To: Björn Ekström; +Cc: pandoc-discuss

Björn Ekström <eksbjo-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:

> Now I just need to figure out how to another filter which removes the
> colon in this bibkey title
>
>  [@organization_endreport:_2016]
>
> since the colon (which is part of the title) creates a syntax error
> with the following underscore.

The line

   references[k].id = v.id[1].text:gsub("%?%?%?%?", "0000") 

can be amended with additional substitution commands. E.g., appending
`:gsub(":_", ":") would replace a colon followed by an underscore with
just a colon.

See the [patterns section] of the Lua manual for details if you are
interested in adding more complicated rules.

[patterns section]: https://www.lua.org/manual/5.3/manual.html#6.4.1

-- 
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 post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/87bmkj42mv.fsf%40zeitkraut.de.
For more options, visit https://groups.google.com/d/optout.


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

* Re: Markdown syntax can't handle BibLaTeX formatting
       [not found]                                 ` <87bmkj42mv.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
@ 2017-11-04  7:04                                   ` Björn Ekström
  0 siblings, 0 replies; 14+ messages in thread
From: Björn Ekström @ 2017-11-04  7:04 UTC (permalink / raw)
  To: pandoc-discuss

[-- Attachment #1: Type: text/plain, Size: 181 bytes --]

So far I got it but I had some issues with running the code. A Ruby script did the job as a workaround, but will try again with Lua.

Thanks a lot for all your help and for pandoc.

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

end of thread, other threads:[~2017-11-04  7:04 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-01 13:25 Markdown syntax can't handle BibLaTeX formatting distantflag
     [not found] ` <90e14ff2-6cec-4dfe-9236-0998cf317b6c-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2017-11-01 16:40   ` John MACFARLANE
2017-11-01 20:40   ` Albert Krewinkel
     [not found]     ` <87tvyd4trv.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
2017-11-02  7:39       ` distantflag
     [not found]         ` <cfc702fb-7389-4b78-88c8-0ec235ffa481-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2017-11-02  7:53           ` Björn Ekström
     [not found]             ` <5fdd83a6-e681-42bf-91b5-1216e605f76b-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2017-11-02 19:22               ` John MACFARLANE
2017-11-02 20:02           ` Albert Krewinkel
     [not found]             ` <87po904ffv.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
2017-11-02 20:22               ` John MACFARLANE
2017-11-02 21:22                 ` Albert Krewinkel
     [not found]                   ` <87k1z84bpy.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
2017-11-02 22:19                     ` John MACFARLANE
2017-11-03  9:37                       ` Björn Ekström
     [not found]                         ` <1de89ee9-9064-4020-8419-4bcf7755cf9b-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2017-11-03  9:56                           ` Björn Ekström
     [not found]                             ` <219efc35-d812-4b40-addd-adaed55955d8-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2017-11-03 18:51                               ` Albert Krewinkel
     [not found]                                 ` <87bmkj42mv.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
2017-11-04  7:04                                   ` Björn Ekström

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