public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* code block translation from latex to html
@ 2020-05-08  0:28 Umut Acar
       [not found] ` <49108dd7-3ee5-41b5-9b8c-92c558ff46b5-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Umut Acar @ 2020-05-08  0:28 UTC (permalink / raw)
  To: pandoc-discuss


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

At some point after pandoc version 2.7.2, pandoc started translating code 
blocks to html from LaTeX sources somewhat differently.  

For example,  the code block

```
\begin{lstlisting} 
...
2 (int) 
\end{lstlisting}
```
used to produce the following html 
```
<a class="sourceLine" id="cb2-4" title="4"><span class="dv">2</span> (<span 
class="dt">int</span>)  
```
It now produces the following
```
<span id="cb2-4"><a href="#cb2-4"></a><span class="dv">2</span> (<span 
class="dt">int</span>)  </span>
```

On a browser,  the latter renders the code "int" as a html link to itself; 
the code line is rendered as a link (to itself).

Also, because the code anchor id's such as `cb2-4` are not unique (multiple 
code blocks generate the same id's), clicking on a code line sends the 
browser to the first instance of that id, usually somewhere up the page.

The new translation is also dropping the code line numbers.

Any thoughts about what might be going on and suggestions about how this 
could be fixed?   I would be happy with the prior behavior code lines were 
not assigned anchor tags and were numbered serially.  




-- 
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/49108dd7-3ee5-41b5-9b8c-92c558ff46b5%40googlegroups.com.

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

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

* Re: code block translation from latex to html
       [not found] ` <49108dd7-3ee5-41b5-9b8c-92c558ff46b5-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2020-05-08  4:45   ` John MacFarlane
       [not found]     ` <m2eerv8279.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: John MacFarlane @ 2020-05-08  4:45 UTC (permalink / raw)
  To: Umut Acar, pandoc-discuss


You need to provide us with more to go on.
By itself this input wouldn't produce highlighted code at all
(no language is specified).

Try this markdown sample:

~~~~~~
One:

``` {.haskell .numberLines}
let x = tail y in
    x <> y
```

Two:

``` {.haskell .numberLines}
x >>= y >>= z
```
~~~~~~

This works fine. Line numbers are generated. The line numbers are
links to the line (very useful!).  The two snippets generate separate
ids with links to separat elines.

Without the 'numberLines' class you don't get the line numbers,
and the lines are NOT links to themselves.

When converting from LaTeX/listings, you'll need to add the
numbers=left option to get numbering.

In your output

<span id="cb2-4"><a href="#cb2-4"></a><span class="dv">2</span> (<span 
class="dt">int</span>)  </span>

the line is not a link to itself (tested on browser just to make
sure); there is an <a> element but its content is empty since
you don't have a line number.






Umut Acar <umutacar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:

> At some point after pandoc version 2.7.2, pandoc started translating code 
> blocks to html from LaTeX sources somewhat differently.  
>
> For example,  the code block
>
> ```
> \begin{lstlisting} 
> ...
> 2 (int) 
> \end{lstlisting}
> ```
> used to produce the following html 
> ```
> <a class="sourceLine" id="cb2-4" title="4"><span class="dv">2</span> (<span 
> class="dt">int</span>)  
> ```
> It now produces the following
> ```
> <span id="cb2-4"><a href="#cb2-4"></a><span class="dv">2</span> (<span 
> class="dt">int</span>)  </span>
> ```
>
> On a browser,  the latter renders the code "int" as a html link to itself; 
> the code line is rendered as a link (to itself).
>
> Also, because the code anchor id's such as `cb2-4` are not unique (multiple 
> code blocks generate the same id's), clicking on a code line sends the 
> browser to the first instance of that id, usually somewhere up the page.
>
> The new translation is also dropping the code line numbers.
>
> Any thoughts about what might be going on and suggestions about how this 
> could be fixed?   I would be happy with the prior behavior code lines were 
> not assigned anchor tags and were numbered serially.  
>
>
>
>
> -- 
> 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/49108dd7-3ee5-41b5-9b8c-92c558ff46b5%40googlegroups.com.


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

* Re: code block translation from latex to html
       [not found]     ` <m2eerv8279.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
@ 2020-05-08 14:09       ` Umut Acar
  2020-06-14  1:19       ` Umut Acar
  1 sibling, 0 replies; 4+ messages in thread
From: Umut Acar @ 2020-05-08 14:09 UTC (permalink / raw)
  To: John MacFarlane; +Cc: pandoc-discuss

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

Hi John, thank you for the response!  Soon after making the post, I
realized that there was more to this than I realized and deleted the
question but I imagine that it had already landed in your mailbox.

The problem seems to be that my code,  which processes pandoc output a bit,
turns empty anchors for line numbers into self closing anchor tags.  These
self closing tags seem to break the browser, which include the whole code
line as the anchor text.  I will look into more closely why and post an
update.  I am a bit puzzled at the moment.


On Fri, May 8, 2020, 12:45 AM John MacFarlane <jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org> wrote:

>
> You need to provide us with more to go on.
> By itself this input wouldn't produce highlighted code at all
> (no language is specified).
>
> Try this markdown sample:
>
> ~~~~~~
> One:
>
> ``` {.haskell .numberLines}
> let x = tail y in
>     x <> y
> ```
>
> Two:
>
> ``` {.haskell .numberLines}
> x >>= y >>= z
> ```
> ~~~~~~
>
> This works fine. Line numbers are generated. The line numbers are
> links to the line (very useful!).  The two snippets generate separate
> ids with links to separat elines.
>
> Without the 'numberLines' class you don't get the line numbers,
> and the lines are NOT links to themselves.
>
> When converting from LaTeX/listings, you'll need to add the
> numbers=left option to get numbering.
>
> In your output
>
> <span id="cb2-4"><a href="#cb2-4"></a><span class="dv">2</span> (<span
> class="dt">int</span>)  </span>
>
> the line is not a link to itself (tested on browser just to make
> sure); there is an <a> element but its content is empty since
> you don't have a line number.
>
>
>
>
>
>
> Umut Acar <umutacar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:
>
> > At some point after pandoc version 2.7.2, pandoc started translating
> code
> > blocks to html from LaTeX sources somewhat differently.
> >
> > For example,  the code block
> >
> > ```
> > \begin{lstlisting}
> > ...
> > 2 (int)
> > \end{lstlisting}
> > ```
> > used to produce the following html
> > ```
> > <a class="sourceLine" id="cb2-4" title="4"><span class="dv">2</span>
> (<span
> > class="dt">int</span>)
> > ```
> > It now produces the following
> > ```
> > <span id="cb2-4"><a href="#cb2-4"></a><span class="dv">2</span> (<span
> > class="dt">int</span>)  </span>
> > ```
> >
> > On a browser,  the latter renders the code "int" as a html link to
> itself;
> > the code line is rendered as a link (to itself).
> >
> > Also, because the code anchor id's such as `cb2-4` are not unique
> (multiple
> > code blocks generate the same id's), clicking on a code line sends the
> > browser to the first instance of that id, usually somewhere up the page.
> >
> > The new translation is also dropping the code line numbers.
> >
> > Any thoughts about what might be going on and suggestions about how this
> > could be fixed?   I would be happy with the prior behavior code lines
> were
> > not assigned anchor tags and were numbered serially.
> >
> >
> >
> >
> > --
> > 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/49108dd7-3ee5-41b5-9b8c-92c558ff46b5%40googlegroups.com
> .
>

-- 
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/CAJ2-sn2Mh79PY4JK3kvcrLMwHgQqmJ6%2BN%2BbDAP%2BW7K_aSaj3oQ%40mail.gmail.com.

[-- Attachment #2: Type: text/html, Size: 6528 bytes --]

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

* Re: code block translation from latex to html
       [not found]     ` <m2eerv8279.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
  2020-05-08 14:09       ` Umut Acar
@ 2020-06-14  1:19       ` Umut Acar
  1 sibling, 0 replies; 4+ messages in thread
From: Umut Acar @ 2020-06-14  1:19 UTC (permalink / raw)
  To: pandoc-discuss


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

Hi John,

Update on this: this turn out to be a html/browser issue.  Basically, 
browsers do not seem to like self-closing anchor tags and  don't render 
them properly (all three browsers I have tried consistently failed).  
Unfortunately, various html processing libraries that I use translate 
("standardize") empty anchors into self-closing anchors.  I got around the 
problem by preventing this from happening by forcing the anchors tags to 
have "empty" text bodies, which the translation tools treat as something 
different that "Null" or "None".  Bottomline, as far as I can tell, there 
is nothing interesting here as far as pandoc is concerned....


On Friday, May 8, 2020 at 12:45:30 AM UTC-4, John MacFarlane wrote:
>
>
> You need to provide us with more to go on. 
> By itself this input wouldn't produce highlighted code at all 
> (no language is specified). 
>
> Try this markdown sample: 
>
> ~~~~~~ 
> One: 
>
> ``` {.haskell .numberLines} 
> let x = tail y in 
>     x <> y 
> ``` 
>
> Two: 
>
> ``` {.haskell .numberLines} 
> x >>= y >>= z 
> ``` 
> ~~~~~~ 
>
> This works fine. Line numbers are generated. The line numbers are 
> links to the line (very useful!).  The two snippets generate separate 
> ids with links to separat elines. 
>
> Without the 'numberLines' class you don't get the line numbers, 
> and the lines are NOT links to themselves. 
>
> When converting from LaTeX/listings, you'll need to add the 
> numbers=left option to get numbering. 
>
> In your output 
>
> <span id="cb2-4"><a href="#cb2-4"></a><span class="dv">2</span> (<span 
> class="dt">int</span>)  </span> 
>
> the line is not a link to itself (tested on browser just to make 
> sure); there is an <a> element but its content is empty since 
> you don't have a line number. 
>
>
>
>
>
>
> Umut Acar <umut...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <javascript:>> writes: 
>
> > At some point after pandoc version 2.7.2, pandoc started translating 
> code 
> > blocks to html from LaTeX sources somewhat differently.   
> > 
> > For example,  the code block 
> > 
> > ``` 
> > \begin{lstlisting} 
> > ... 
> > 2 (int) 
> > \end{lstlisting} 
> > ``` 
> > used to produce the following html 
> > ``` 
> > <a class="sourceLine" id="cb2-4" title="4"><span class="dv">2</span> 
> (<span 
> > class="dt">int</span>)   
> > ``` 
> > It now produces the following 
> > ``` 
> > <span id="cb2-4"><a href="#cb2-4"></a><span class="dv">2</span> (<span 
> > class="dt">int</span>)  </span> 
> > ``` 
> > 
> > On a browser,  the latter renders the code "int" as a html link to 
> itself; 
> > the code line is rendered as a link (to itself). 
> > 
> > Also, because the code anchor id's such as `cb2-4` are not unique 
> (multiple 
> > code blocks generate the same id's), clicking on a code line sends the 
> > browser to the first instance of that id, usually somewhere up the page. 
> > 
> > The new translation is also dropping the code line numbers. 
> > 
> > Any thoughts about what might be going on and suggestions about how this 
> > could be fixed?   I would be happy with the prior behavior code lines 
> were 
> > not assigned anchor tags and were numbered serially.   
> > 
> > 
> > 
> > 
> > -- 
> > 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-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <javascript:>. 
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/pandoc-discuss/49108dd7-3ee5-41b5-9b8c-92c558ff46b5%40googlegroups.com. 
>
>

-- 
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/f34f1376-c7cb-46f2-94c7-771c144dd239o%40googlegroups.com.

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

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

end of thread, other threads:[~2020-06-14  1:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-08  0:28 code block translation from latex to html Umut Acar
     [not found] ` <49108dd7-3ee5-41b5-9b8c-92c558ff46b5-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-05-08  4:45   ` John MacFarlane
     [not found]     ` <m2eerv8279.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
2020-05-08 14:09       ` Umut Acar
2020-06-14  1:19       ` Umut Acar

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