emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* how to handle backend-specific types as fuzzy link targets during export
@ 2014-06-24 10:59 Eric Schulte
  2014-06-24 11:56 ` Nicolas Goaziou
  0 siblings, 1 reply; 8+ messages in thread
From: Eric Schulte @ 2014-06-24 10:59 UTC (permalink / raw)
  To: Org Mode Mailing List

Hello,

In the function `org-export-resolve-fuzzy-link' at line 4078 of ox.el
the `org-element-all-elements' variable is used to map over all elements
in the parse tree when looking for a possible link target.  However some
trees hold valid backend-specific types which are not members of the
`org-element-all-elements' variable (e.g., `latex-fragment').  This
results in named targets not being resolved during export.

I'm currently working around this locally by let-binding
`org-element-all-elements' in line 1967 of ox-latex.el, but I imagine
there should be a more general solution.

Thoughts?

Thanks,
Eric

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)

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

* Re: how to handle backend-specific types as fuzzy link targets during export
  2014-06-24 10:59 how to handle backend-specific types as fuzzy link targets during export Eric Schulte
@ 2014-06-24 11:56 ` Nicolas Goaziou
  2014-06-24 12:46   ` Eric Schulte
  0 siblings, 1 reply; 8+ messages in thread
From: Nicolas Goaziou @ 2014-06-24 11:56 UTC (permalink / raw)
  To: Eric Schulte; +Cc: Org Mode Mailing List

Hello,

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

> In the function `org-export-resolve-fuzzy-link' at line 4078 of ox.el
> the `org-element-all-elements' variable is used to map over all elements
> in the parse tree when looking for a possible link target.  However some
> trees hold valid backend-specific types which are not members of the
> `org-element-all-elements' variable (e.g., `latex-fragment').  This
> results in named targets not being resolved during export.

I do not understand what you are trying to achieve. Line 4078 tries to
find elements with a #+NAME affiliated keyword in the parse tree. LaTeX
fragments cannot have such keywords.

Maybe an example would help.


Regards,

-- 
Nicolas Goaziou

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

* Re: how to handle backend-specific types as fuzzy link targets during export
  2014-06-24 11:56 ` Nicolas Goaziou
@ 2014-06-24 12:46   ` Eric Schulte
  2014-06-24 13:08     ` Nicolas Goaziou
  0 siblings, 1 reply; 8+ messages in thread
From: Eric Schulte @ 2014-06-24 12:46 UTC (permalink / raw)
  To: Eric Schulte; +Cc: Org Mode Mailing List

Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:

> Hello,
>
> Eric Schulte <schulte.eric@gmail.com> writes:
>
>> In the function `org-export-resolve-fuzzy-link' at line 4078 of ox.el
>> the `org-element-all-elements' variable is used to map over all elements
>> in the parse tree when looking for a possible link target.  However some
>> trees hold valid backend-specific types which are not members of the
>> `org-element-all-elements' variable (e.g., `latex-fragment').  This
>> results in named targets not being resolved during export.
>
> I do not understand what you are trying to achieve. Line 4078 tries to
> find elements with a #+NAME affiliated keyword in the parse tree. LaTeX
> fragments cannot have such keywords.
>
> Maybe an example would help.
>

Sure.  I have added a function to org-export-filter-parse-tree-functions
which replaces a custom keyword with either a latex-fragment or an HTML
link wrapped in a paragraph depending on the export backend.  The latex
fragment basically has the following content,

    "\\begin{figure}
      \\centering
      \\input{%s}
      \\caption[%s]{\\label{%s}%s}
    \\end{figure}\n\n"

and I assign it a :name property to match the label in the above.  I
then have links elsewhere in the file which reference this label.

Is there a better way to achieve output like the above?  If not I think
an argument can be made that either (1) after filters have run
assumptions about which types can support which properties are moot, or
(2) there should be a way to have a filter insert a named chunk of
backend-specific code.

Thanks,
Eric

>
>
> Regards,

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)

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

* Re: how to handle backend-specific types as fuzzy link targets during export
  2014-06-24 12:46   ` Eric Schulte
@ 2014-06-24 13:08     ` Nicolas Goaziou
  2014-06-24 13:30       ` Eric Schulte
  0 siblings, 1 reply; 8+ messages in thread
From: Nicolas Goaziou @ 2014-06-24 13:08 UTC (permalink / raw)
  To: Eric Schulte; +Cc: Org Mode Mailing List

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

> Sure.  I have added a function to org-export-filter-parse-tree-functions
> which replaces a custom keyword with either a latex-fragment or an HTML
> link wrapped in a paragraph depending on the export backend.  The latex
> fragment basically has the following content,
>
>     "\\begin{figure}
>       \\centering
>       \\input{%s}
>       \\caption[%s]{\\label{%s}%s}
>     \\end{figure}\n\n"
>
> and I assign it a :name property to match the label in the above.  I
> then have links elsewhere in the file which reference this label.

I still do not get it. Could you show your (possibly simplified) filter
function?

Also, what code do you want ox-latex to generate?

Note that #+NAME is internal Org syntax. It cannot possibly be
compatible with random raw LaTeX code. IOW, even if you can write raw
LaTeX in an Org buffer, it doesn't mean that Org will understand the
LaTeX code you wrote.


Regards,

-- 
Nicolas Goaziou

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

* Re: how to handle backend-specific types as fuzzy link targets during export
  2014-06-24 13:08     ` Nicolas Goaziou
@ 2014-06-24 13:30       ` Eric Schulte
  2014-06-24 15:28         ` Nicolas Goaziou
  0 siblings, 1 reply; 8+ messages in thread
From: Eric Schulte @ 2014-06-24 13:30 UTC (permalink / raw)
  To: Org Mode Mailing List

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

Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:

> Eric Schulte <schulte.eric@gmail.com> writes:
>
>> Sure.  I have added a function to org-export-filter-parse-tree-functions
>> which replaces a custom keyword with either a latex-fragment or an HTML
>> link wrapped in a paragraph depending on the export backend.  The latex
>> fragment basically has the following content,
>>
>>     "\\begin{figure}
>>       \\centering
>>       \\input{%s}
>>       \\caption[%s]{\\label{%s}%s}
>>     \\end{figure}\n\n"
>>
>> and I assign it a :name property to match the label in the above.  I
>> then have links elsewhere in the file which reference this label.
>
> I still do not get it. Could you show your (possibly simplified) filter
> function?
>

Attached


[-- Attachment #2: tikz-figure-keywords.el --]
[-- Type: application/emacs-lisp, Size: 2211 bytes --]

[-- Attachment #3: Type: text/plain, Size: 919 bytes --]


>
> Also, what code do you want ox-latex to generate?
>

So something like the following

    #+name: technique-overview
    #+Caption[Overview of Technique]: Text.
    #+TIKZ_FIGURE: technique-overview

    Lorem ipsum dolor sit amet Figure [[technique-overview]] posuere.

results in something like the following for latex export

    \begin{figure}
      \centering
      \input{technique-overview}
      \caption[Overview of Technique]{\label{technique-overview}Text.}
    \end{figure}

     Lorem ipsum dolor sit amet Figure \ref{technique-overview} posuere.

Thanks,
Eric

>
> Note that #+NAME is internal Org syntax. It cannot possibly be
> compatible with random raw LaTeX code. IOW, even if you can write raw
> LaTeX in an Org buffer, it doesn't mean that Org will understand the
> LaTeX code you wrote.
>
>
> Regards,

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)

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

* Re: how to handle backend-specific types as fuzzy link targets during export
  2014-06-24 13:30       ` Eric Schulte
@ 2014-06-24 15:28         ` Nicolas Goaziou
  2014-06-30 16:37           ` Eric Schulte
  0 siblings, 1 reply; 8+ messages in thread
From: Nicolas Goaziou @ 2014-06-24 15:28 UTC (permalink / raw)
  To: Eric Schulte; +Cc: Org Mode Mailing List

Hello,

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

> Attached

OK, now I get it.

You're working at the wrong level. `latex-fragment' is an object
(inline) type, but you're inserting it at the element's level. The
equivalent (non inline) element is `latex-environment', which is, for
example:

  \begin{equation}
  1+1=2
  \end{equation}

So you could simply replace `latex-fragment' type with
`latex-environment', and your example should work properly.

HTH,


Regards,

-- 
Nicolas Goaziou

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

* Re: how to handle backend-specific types as fuzzy link targets during export
  2014-06-24 15:28         ` Nicolas Goaziou
@ 2014-06-30 16:37           ` Eric Schulte
  2014-06-30 20:29             ` Nicolas Goaziou
  0 siblings, 1 reply; 8+ messages in thread
From: Eric Schulte @ 2014-06-30 16:37 UTC (permalink / raw)
  To: Eric Schulte; +Cc: Org Mode Mailing List

Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:

> Hello,
>
> Eric Schulte <schulte.eric@gmail.com> writes:
>
>> Attached
>
> OK, now I get it.
>
> You're working at the wrong level. `latex-fragment' is an object
> (inline) type, but you're inserting it at the element's level. The
> equivalent (non inline) element is `latex-environment', which is, for
> example:
>
>   \begin{equation}
>   1+1=2
>   \end{equation}
>
> So you could simply replace `latex-fragment' type with
> `latex-environment', and your example should work properly.
>

Confirmed, using `latex-environment' does give the desired behavior.

A related question.  Is there a command to re-number figures in export?
After adding latex-environments in a function added to the
`org-export-filter-parse-tree-functions' hook, all figures are numbered
"1".

Thanks,

>
> HTH,
>
>
> Regards,

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)

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

* Re: how to handle backend-specific types as fuzzy link targets during export
  2014-06-30 16:37           ` Eric Schulte
@ 2014-06-30 20:29             ` Nicolas Goaziou
  0 siblings, 0 replies; 8+ messages in thread
From: Nicolas Goaziou @ 2014-06-30 20:29 UTC (permalink / raw)
  To: Eric Schulte; +Cc: Org Mode Mailing List

Hello,

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

> A related question.  Is there a command to re-number figures in
> export?

Figures are not numbered in the parse tree: their number is computed on
the fly during export, with `org-export-get-ordinal'.

> After adding latex-environments in a function added to the
> `org-export-filter-parse-tree-functions' hook, all figures are numbered
> "1".

See my answer in the other thread. The simplest solution is to add
a caption to them.


Regards,

-- 
Nicolas Goaziou

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

end of thread, other threads:[~2014-06-30 20:29 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-24 10:59 how to handle backend-specific types as fuzzy link targets during export Eric Schulte
2014-06-24 11:56 ` Nicolas Goaziou
2014-06-24 12:46   ` Eric Schulte
2014-06-24 13:08     ` Nicolas Goaziou
2014-06-24 13:30       ` Eric Schulte
2014-06-24 15:28         ` Nicolas Goaziou
2014-06-30 16:37           ` Eric Schulte
2014-06-30 20:29             ` 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).