public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* Md to Md: Issue while converting to Reference Links, if file contains both Inline and Reference Link
@ 2018-12-24 12:28 Nikhil Agarwal
       [not found] ` <bf0da71a-2001-45d7-8ec1-3495ad328b39-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Nikhil Agarwal @ 2018-12-24 12:28 UTC (permalink / raw)
  To: pandoc-discuss


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

I am trying to convert all links in a markdown file to Reference Links. 
Sometimes, the original file contains both Inline and Reference Link. e.g.

```markdown
- A **web app** is a [client--server] [computer program](
https://en.wikipedia.org/wiki/Computer_program "Computer program").

[client--server]: https://en.wikipedia.org/wiki/Client%E2%80%93server_model 
"Client–server model"
```

becomes
```markdown
- A **web app** is a \[client--server\] [computer program].

[client--server]: https://en.wikipedia.org/wiki/Client%E2%80%93server_model 
"Client–server model"
[computer program]: https://en.wikipedia.org/wiki/Computer_program "Computer 
program"
```

The issue comes when, I render it to HTML, and the `client--server` link in 
the above example doesn't work anymore, as the square brackets are escaped.

What do you suggest?

Thanks!


-- 
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/bf0da71a-2001-45d7-8ec1-3495ad328b39%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

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

* Re: Md to Md: Issue while converting to Reference Links, if file contains both Inline and Reference Link
       [not found] ` <bf0da71a-2001-45d7-8ec1-3495ad328b39-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2018-12-24 13:59   ` Nikhil Agarwal
  2018-12-26 22:18   ` John MacFarlane
  1 sibling, 0 replies; 3+ messages in thread
From: Nikhil Agarwal @ 2018-12-24 13:59 UTC (permalink / raw)
  To: pandoc-discuss


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

Temporarily, I am solving this issue by using the following python code  
(but there can be some false positives)

```python
import sys
import re

Pattern = '\\\\\[(.*?)\\\\\]' # Non greedy pattern # Refer: 1, 2
Output = re.sub(Pattern, '[\\1]', sys.stdin.read())
print(Output)
```

On Monday, 24 December 2018 13:28:56 UTC+1, Nikhil Agarwal wrote:
>
> I am trying to convert all links in a markdown file to Reference Links. 
> Sometimes, the original file contains both Inline and Reference Link. e.g.
>
> ```markdown
> - A **web app** is a [client--server] [computer program](
> https://en.wikipedia.org/wiki/Computer_program "Computer program").
>
> [client--server]: 
> https://en.wikipedia.org/wiki/Client%E2%80%93server_model "Client–server 
> model"
> ```
>
> becomes
> ```markdown
> - A **web app** is a \[client--server\] [computer program].
>
> [client--server]: 
> https://en.wikipedia.org/wiki/Client%E2%80%93server_model "Client–server 
> model"
> [computer program]: https://en.wikipedia.org/wiki/Computer_program "Computer 
> program"
> ```
>
> The issue comes when, I render it to HTML, and the `client--server` link 
> in the above example doesn't work anymore, as the square brackets are 
> escaped.
>
> What do you suggest?
>
> Thanks!
>
>
>

-- 
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/ee5d9253-9a49-4581-94a1-f07266885cc8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

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

* Re: Md to Md: Issue while converting to Reference Links, if file contains both Inline and Reference Link
       [not found] ` <bf0da71a-2001-45d7-8ec1-3495ad328b39-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  2018-12-24 13:59   ` Nikhil Agarwal
@ 2018-12-26 22:18   ` John MacFarlane
  1 sibling, 0 replies; 3+ messages in thread
From: John MacFarlane @ 2018-12-26 22:18 UTC (permalink / raw)
  To: Nikhil Agarwal, pandoc-discuss


Try using

pandoc -t markdown-shortcut_reference_links --reference-links

Then you'll get:

-   A **web app** is a [client--server][] [computer program][].

  [client--server]: https://en.wikipedia.org/wiki/Client%E2%80%93server_model
    "Client–server model"
  [computer program]: https://en.wikipedia.org/wiki/Computer_program
    "Computer program"

--

It would be desirable to make pandoc smarter, so it
generates the output


-   A **web app** is a [client--server][] [computer program].

  [client--server]: https://en.wikipedia.org/wiki/Client%E2%80%93server_model
    "Client–server model"
  [computer program]: https://en.wikipedia.org/wiki/Computer_program
    "Computer program"

even without `-shortcut_reference_links`, and doesn't
escape the brackets.  (Just avoiding the escaping
would not work, because pandoc would treat

    [client-server] [computer program]

as a single reference link to the second URL.

In CommonMark we've tightened up reference links so
that there can't be a space between the two parts,
which helps avoid problems like this. We may want to
make the same change now in pandoc's markdown parser,
though I'm hesitant, as it might break some
existing documents.

-- 
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/m21s649bkr.fsf%40johnmacfarlane.net.
For more options, visit https://groups.google.com/d/optout.


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

end of thread, other threads:[~2018-12-26 22:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-24 12:28 Md to Md: Issue while converting to Reference Links, if file contains both Inline and Reference Link Nikhil Agarwal
     [not found] ` <bf0da71a-2001-45d7-8ec1-3495ad328b39-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2018-12-24 13:59   ` Nikhil Agarwal
2018-12-26 22:18   ` John MacFarlane

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