public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* markdown - pdf two way sync
@ 2016-05-03  9:42 Andrey Ustyuzhanin
       [not found] ` <aeb78b6e-ed06-4d86-ac4b-0a6d7385fbf7-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Andrey Ustyuzhanin @ 2016-05-03  9:42 UTC (permalink / raw)
  To: pandoc-discuss


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

Hi all!

I use pandoc to generate slides of my presentation from markdown. And one 
useful use-case would be to navigate from PDF to source and back (think of 
PDF-Sync 
https://sourceforge.net/p/skim-app/wiki/TeX_and_PDF_Synchronization/#tex-pdf-synchronization). 
Are there any out-of-the-box receipts I can follow? otherwise I thought 
such synchronization can be performed if pandoc allowed to store mapping 
between md and tex files. But I couldn't find any hint how can I do it?
Thank you in advance! 

-- 
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/aeb78b6e-ed06-4d86-ac4b-0a6d7385fbf7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

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

* Re: markdown - pdf two way sync
       [not found] ` <aeb78b6e-ed06-4d86-ac4b-0a6d7385fbf7-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2016-05-03 18:38   ` John MACFARLANE
       [not found]     ` <20160503183852.GA21146-nFAEphtLEs/fysO+viCLMa55KtNWUUjk@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: John MACFARLANE @ 2016-05-03 18:38 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

Pandoc doesn't store any source-mapping information in
the AST.

+++ Andrey Ustyuzhanin [May 03 16 02:42 ]:
>   Hi all!
>   I use pandoc to generate slides of my presentation from markdown. And
>   one useful use-case would be to navigate from PDF to source and back
>   (think of PDF-Sync
>   https://sourceforge.net/p/skim-app/wiki/TeX_and_PDF_Synchronization/#te
>   x-pdf-synchronization). Are there any out-of-the-box receipts I can
>   follow? otherwise I thought such synchronization can be performed if
>   pandoc allowed to store mapping between md and tex files. But I
>   couldn't find any hint how can I do it?
>   Thank you in advance!
>
>   --
>   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/aeb78b6e-ed06-4d86-
>   ac4b-0a6d7385fbf7%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/aeb78b6e-ed06-4d86-ac4b-0a6d7385fbf7-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org?utm_medium=email&utm_source=footer
>   4. https://groups.google.com/d/optout


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

* Re: markdown - pdf two way sync
       [not found]     ` <20160503183852.GA21146-nFAEphtLEs/fysO+viCLMa55KtNWUUjk@public.gmane.org>
@ 2016-05-14 15:50       ` BH
       [not found]         ` <d6c717a4-11c4-47f7-88b7-37ff0f9b394f-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: BH @ 2016-05-14 15:50 UTC (permalink / raw)
  To: pandoc-discuss


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

On Tuesday, May 3, 2016 at 2:39:05 PM UTC-4, John MacFarlane wrote:
>
> Pandoc doesn't store any source-mapping information in 
> the AST. 
>

This is, of course, right, but two-way sync (in both directions) is 
possible nonetheless (albeit in a way that's quite fragile). Here's the 
rough idea (both requiring that pdfsync be used when compiling the .pdf 
file):

1. For backward search (from .pdf to .md): have the .pdf viewer send the 
source (.tex) file and line number to a script that (a) reads in the 
relevant line from the .tex file, (b) extracts a reasonable-sized chunk of 
text, (c) searches for that text in the corresponding markdown file, and 
finally (d) sends the line number of that text to the text editor.

2. For forward search (from .md to .pdf) do the opposite: have the text 
editor send the source (.md) file and line number to a script that (a) 
reads in the relevant line from the .md file, (b) extracts a 
reasonable-sized chunk of text, (c) searches for that text in the 
corresponding .tex file, and finally (d) sends the line number of that text 
to the .pdf viewer.

Clearly, a problem lies in step (b) in both cases: how do you locate the 
relevant text to use in searching the corresponding file for? What I've 
done differs between (1) and (2).

In (2), I find it easiest to take the whole line of markdown, strip off any 
initial markdown codes (such as those for enumerated lists), run it through 
pandoc (using exactly the same options I use to generate the .pdf in the 
first place) to convert to LaTeX, and then search for this in the .tex file.

In (1), I find I need to use a different strategy, since .tex -> .md 
conversion in pandoc often fails to produce a match in the .md file. (This 
is partly because of the way I have extended markdown using some filters.) 
So here I try to locate a stretch of text in the .tex file that does not 
contain any LaTeX commands as follows: I try searching for the first 
occurrence of '\' in the relevant line, and if this occurs deep enough into 
the text, I grab text from the beginning of the line to that point. If not, 
I look for a stretch of text after that '\' that occurs between '{' and 
'}'. Usually this is good enough to find a unique match in the markdown 
file.

As I said, this is fragile: it won't work in every case, but for me it 
works about 90-95% of the time, which is good enough for my purposes.

-- 
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/d6c717a4-11c4-47f7-88b7-37ff0f9b394f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

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

* Re: markdown - pdf two way sync
       [not found]         ` <d6c717a4-11c4-47f7-88b7-37ff0f9b394f-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2023-05-23  8:50           ` J
  0 siblings, 0 replies; 4+ messages in thread
From: J @ 2023-05-23  8:50 UTC (permalink / raw)
  To: pandoc-discuss


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

Is it possible to sync between markdown and pdf, or between markdown and 
docx nowadays ? Many thanks !

On Saturday, May 14, 2016 at 11:50:25 PM UTC+8 BH wrote:

> On Tuesday, May 3, 2016 at 2:39:05 PM UTC-4, John MacFarlane wrote:
>>
>> Pandoc doesn't store any source-mapping information in 
>> the AST. 
>>
>
> This is, of course, right, but two-way sync (in both directions) is 
> possible nonetheless (albeit in a way that's quite fragile). Here's the 
> rough idea (both requiring that pdfsync be used when compiling the .pdf 
> file):
>
> 1. For backward search (from .pdf to .md): have the .pdf viewer send the 
> source (.tex) file and line number to a script that (a) reads in the 
> relevant line from the .tex file, (b) extracts a reasonable-sized chunk of 
> text, (c) searches for that text in the corresponding markdown file, and 
> finally (d) sends the line number of that text to the text editor.
>
> 2. For forward search (from .md to .pdf) do the opposite: have the text 
> editor send the source (.md) file and line number to a script that (a) 
> reads in the relevant line from the .md file, (b) extracts a 
> reasonable-sized chunk of text, (c) searches for that text in the 
> corresponding .tex file, and finally (d) sends the line number of that text 
> to the .pdf viewer.
>
> Clearly, a problem lies in step (b) in both cases: how do you locate the 
> relevant text to use in searching the corresponding file for? What I've 
> done differs between (1) and (2).
>
> In (2), I find it easiest to take the whole line of markdown, strip off 
> any initial markdown codes (such as those for enumerated lists), run it 
> through pandoc (using exactly the same options I use to generate the .pdf 
> in the first place) to convert to LaTeX, and then search for this in the 
> .tex file.
>
> In (1), I find I need to use a different strategy, since .tex -> .md 
> conversion in pandoc often fails to produce a match in the .md file. (This 
> is partly because of the way I have extended markdown using some filters.) 
> So here I try to locate a stretch of text in the .tex file that does not 
> contain any LaTeX commands as follows: I try searching for the first 
> occurrence of '\' in the relevant line, and if this occurs deep enough into 
> the text, I grab text from the beginning of the line to that point. If not, 
> I look for a stretch of text after that '\' that occurs between '{' and 
> '}'. Usually this is good enough to find a unique match in the markdown 
> file.
>
> As I said, this is fragile: it won't work in every case, but for me it 
> works about 90-95% of the time, which is good enough for my purposes.
>

-- 
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/7ede943a-4651-480d-9d87-45eb0cb1f19bn%40googlegroups.com.

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

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

end of thread, other threads:[~2023-05-23  8:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-03  9:42 markdown - pdf two way sync Andrey Ustyuzhanin
     [not found] ` <aeb78b6e-ed06-4d86-ac4b-0a6d7385fbf7-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2016-05-03 18:38   ` John MACFARLANE
     [not found]     ` <20160503183852.GA21146-nFAEphtLEs/fysO+viCLMa55KtNWUUjk@public.gmane.org>
2016-05-14 15:50       ` BH
     [not found]         ` <d6c717a4-11c4-47f7-88b7-37ff0f9b394f-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2023-05-23  8:50           ` J

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