emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* ox-bibtex.el -- how to join sequential citations
@ 2013-11-23 16:23 Eric Schulte
  2013-11-24  2:59 ` Feng Shu
  0 siblings, 1 reply; 6+ messages in thread
From: Eric Schulte @ 2013-11-23 16:23 UTC (permalink / raw)
  To: Org Mode Mailing List

Hi,

I've been using ox-bibtex.el for a couple of days now and am really
enjoying both the bibtex integration and the HTML export through
bibtex2html.  I have run into one issue which I'm now sure how best to
fix.

When exporting multiple sequential citations e.g., cite:foo cite:bar
etc... I would like to see something like the following (latex used for
this example) "\cite{foo, bar}", but instead I'm getting "\cite{foo}
\cite{bar}", which leads to poorly formed PDFs (a similar thing happens
for HTML export).

My question is how best to fix this, should I write a filter function,
or does the export engine already have processes in place to handle
these sorts of export context issues?

Thanks,

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D

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

* Re: ox-bibtex.el -- how to join sequential citations
  2013-11-23 16:23 ox-bibtex.el -- how to join sequential citations Eric Schulte
@ 2013-11-24  2:59 ` Feng Shu
  2013-11-24  9:42   ` Nicolas Goaziou
  0 siblings, 1 reply; 6+ messages in thread
From: Feng Shu @ 2013-11-24  2:59 UTC (permalink / raw)
  To: emacs-orgmode

Eric Schulte <schulte.eric@gmail.com> writes:

> Hi,
>
> I've been using ox-bibtex.el for a couple of days now and am really
> enjoying both the bibtex integration and the HTML export through
> bibtex2html.  I have run into one issue which I'm now sure how best to
> fix.
>
> When exporting multiple sequential citations e.g., cite:foo cite:bar
> etc... I would like to see something like the following (latex used for
> this example) "\cite{foo, bar}", but instead I'm getting "\cite{foo}
> \cite{bar}", which leads to poorly formed PDFs (a similar thing happens
> for HTML export).

May be you should use \cite{foo, bar} directly in org file.

>
> My question is how best to fix this, should I write a filter function,
> or does the export engine already have processes in place to handle
> these sorts of export context issues?
>
> Thanks,

-- 

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

* Re: ox-bibtex.el -- how to join sequential citations
  2013-11-24  2:59 ` Feng Shu
@ 2013-11-24  9:42   ` Nicolas Goaziou
  2013-11-26 13:16     ` Eric Schulte
  0 siblings, 1 reply; 6+ messages in thread
From: Nicolas Goaziou @ 2013-11-24  9:42 UTC (permalink / raw)
  To: Feng Shu; +Cc: emacs-orgmode

Hello,

Feng Shu <tumashu@gmail.com> writes:

> Eric Schulte <schulte.eric@gmail.com> writes:
>
>> When exporting multiple sequential citations e.g., cite:foo cite:bar
>> etc... I would like to see something like the following (latex used for
>> this example) "\cite{foo, bar}", but instead I'm getting "\cite{foo}
>> \cite{bar}", which leads to poorly formed PDFs (a similar thing happens
>> for HTML export).
>
> May be you should use \cite{foo, bar} directly in org file.

That was, indeed, the original way to handle citations in the former
org-export-bibtex.el. It is still supported in both LaTeX, obviously,
and HTML (which will split the above among two anchors).

"cite" link support was added later, and is lacking in this area.

>> My question is how best to fix this, should I write a filter function,
>> or does the export engine already have processes in place to handle
>> these sorts of export context issues?

At the user level, a filter is definitely the way to go.

Though, it is an interesting feature to implement in ox-bibtex.el. One
idea would be to write another parse-tree filter function which would
change cite links into \cite{...} commands and consecutive cite links
into \cite{..., ...} commands.

This would also allow us to get rid of both `org-html-link' and
`org-latex-link' advices, as no more cite link would be left in the
parse tree anyway.

What do you think?


Regards,

-- 
Nicolas Goaziou

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

* Re: ox-bibtex.el -- how to join sequential citations
  2013-11-24  9:42   ` Nicolas Goaziou
@ 2013-11-26 13:16     ` Eric Schulte
  2013-11-26 17:03       ` Nicolas Goaziou
  0 siblings, 1 reply; 6+ messages in thread
From: Eric Schulte @ 2013-11-26 13:16 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Feng Shu, emacs-orgmode

Nicolas Goaziou <n.goaziou@gmail.com> writes:

> Hello,
>
> Feng Shu <tumashu@gmail.com> writes:
>
>> Eric Schulte <schulte.eric@gmail.com> writes:
>>
>>> When exporting multiple sequential citations e.g., cite:foo cite:bar
>>> etc... I would like to see something like the following (latex used for
>>> this example) "\cite{foo, bar}", but instead I'm getting "\cite{foo}
>>> \cite{bar}", which leads to poorly formed PDFs (a similar thing happens
>>> for HTML export).
>>
>> May be you should use \cite{foo, bar} directly in org file.
>
> That was, indeed, the original way to handle citations in the former
> org-export-bibtex.el. It is still supported in both LaTeX, obviously,
> and HTML (which will split the above among two anchors).
>
> "cite" link support was added later, and is lacking in this area.
>
>>> My question is how best to fix this, should I write a filter function,
>>> or does the export engine already have processes in place to handle
>>> these sorts of export context issues?
>
> At the user level, a filter is definitely the way to go.
>

Thanks, the following seems to be working.  Perhaps the filter function
should be added to ox-bibtex.el?

    (defun org-bibtex-group-citations (text backend info)
      "Convert begin/end{verbatim} to begin/end{Verbatim}.
      Allows use of the fancyvrb latex package."
      (with-temp-buffer
        (insert text) (goto-char (point-min))
        (cond
         ((org-export-derived-backend-p backend 'latex)
          (while (re-search-forward
                  "\\\\cite{\\([^[:space:]\n\r]+\\)}[[:space:]\n\r]*\\\\cite{"
                  nil t)
            (replace-match "\\\\cite{\\1,")
            (goto-char (point-min))))
         ((org-export-derived-backend-p backend 'html)
          (while (re-search-forward
                  "\\(#[[:alnum:]]+\">[0-9]+<\/a>\\)\\][[:space:]\n\r]*\\[\\(<a href=\"#[[:alnum:]]+\">[0-9]+<\/a>\\)"
                  nil t)
            (replace-match "\\1,\\2")
            (goto-char (point-min)))))
        (buffer-string)))

    (add-to-list 'org-export-filter-final-output-functions
                 'org-bibtex-group-citations)

Cheers,

>
> Though, it is an interesting feature to implement in ox-bibtex.el. One
> idea would be to write another parse-tree filter function which would
> change cite links into \cite{...} commands and consecutive cite links
> into \cite{..., ...} commands.
>
> This would also allow us to get rid of both `org-html-link' and
> `org-latex-link' advices, as no more cite link would be left in the
> parse tree anyway.
>
> What do you think?
>
>
> Regards,

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D

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

* Re: ox-bibtex.el -- how to join sequential citations
  2013-11-26 13:16     ` Eric Schulte
@ 2013-11-26 17:03       ` Nicolas Goaziou
  2013-12-01 16:08         ` Nicolas Goaziou
  0 siblings, 1 reply; 6+ messages in thread
From: Nicolas Goaziou @ 2013-11-26 17:03 UTC (permalink / raw)
  To: Eric Schulte; +Cc: Feng Shu, emacs-orgmode

Hello,

Eric Schulte <schulte.eric@gmail.com> writes:

> Thanks, the following seems to be working.  Perhaps the filter function
> should be added to ox-bibtex.el?

Thanks for sharing your filter.

Though, if we include it in ox-bibtex (and I agree we should), it would
be better to make it more robust and use a parse tree filter instead.
Then we will be able to operate on objects instead of strings and
regexps.

I will have a look at it, but I'm not sure it will happen before the end
of the week.


Regards,

-- 
Nicolas Goaziou

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

* Re: ox-bibtex.el -- how to join sequential citations
  2013-11-26 17:03       ` Nicolas Goaziou
@ 2013-12-01 16:08         ` Nicolas Goaziou
  0 siblings, 0 replies; 6+ messages in thread
From: Nicolas Goaziou @ 2013-12-01 16:08 UTC (permalink / raw)
  To: Eric Schulte; +Cc: Feng Shu, emacs-orgmode

Nicolas Goaziou <n.goaziou@gmail.com> writes:

> I will have a look at it, but I'm not sure it will happen before the end
> of the week.

Done.


Regards,

-- 
Nicolas Goaziou

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

end of thread, other threads:[~2013-12-01 16:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-23 16:23 ox-bibtex.el -- how to join sequential citations Eric Schulte
2013-11-24  2:59 ` Feng Shu
2013-11-24  9:42   ` Nicolas Goaziou
2013-11-26 13:16     ` Eric Schulte
2013-11-26 17:03       ` Nicolas Goaziou
2013-12-01 16:08         ` Nicolas Goaziou

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).