* auto_identifiers (-) -> (_)
@ 2019-05-21 8:52 Mehran Baghi
[not found] ` <8f31ab60-ab45-4201-bac1-c420438b7b0a-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
0 siblings, 1 reply; 10+ messages in thread
From: Mehran Baghi @ 2019-05-21 8:52 UTC (permalink / raw)
To: pandoc-discuss
[-- Attachment #1.1: Type: text/plain, Size: 892 bytes --]
The auto_identifiers extension replaces all spaces to hyphens.
https://pandoc.org/MANUAL.html#headings-and-sections
I need it to replace them to underscores to keep my website urls uniform.
I have searched the github repo and couldn't find the extension file to fix
it myself.
Is it Extensions.hs ? How can I fix it?
--
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/8f31ab60-ab45-4201-bac1-c420438b7b0a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
[-- Attachment #1.2: Type: text/html, Size: 1401 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: auto_identifiers (-) -> (_)
[not found] ` <8f31ab60-ab45-4201-bac1-c420438b7b0a-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2019-05-21 16:40 ` John MacFarlane
[not found] ` <m24l5nrc9z.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
0 siblings, 1 reply; 10+ messages in thread
From: John MacFarlane @ 2019-05-21 16:40 UTC (permalink / raw)
To: Mehran Baghi, pandoc-discuss
The easiest approach would be to use a lua filter to
modify the identifiers added by auto_identifiers.
Then you don't need to modify the Haskell code.
See the documentation on the website for lua filters.
It would be a few lines.
Mehran Baghi <1mehranbaghi-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:
> The auto_identifiers extension replaces all spaces to hyphens.
>
> https://pandoc.org/MANUAL.html#headings-and-sections
>
> I need it to replace them to underscores to keep my website urls uniform.
> I have searched the github repo and couldn't find the extension file to fix
> it myself.
> Is it Extensions.hs ? How can I fix it?
>
> --
> 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/8f31ab60-ab45-4201-bac1-c420438b7b0a%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: auto_identifiers (-) -> (_)
[not found] ` <m24l5nrc9z.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
@ 2019-05-21 17:41 ` Mehran Baghi
[not found] ` <962ba188-1047-467d-9af6-6f0f30242aa1-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
0 siblings, 1 reply; 10+ messages in thread
From: Mehran Baghi @ 2019-05-21 17:41 UTC (permalink / raw)
To: pandoc-discuss
[-- Attachment #1.1: Type: text/plain, Size: 2359 bytes --]
Thank you Dr. MacFarlane.
The problem with writing a filter to replace (-)s to (_)s is you wouldn't
know
whether the hyphen was a space and auto_identifiers turned it to a hyphen,
or it was a hyphen in the first place.
Is there any other options?
I don't know any haskell yet, but I guess in this case it would be as easy
as
changing a character (-) -> (_). I just don't know where to look.
On Tuesday, May 21, 2019 at 9:11:14 PM UTC+4:30, John MacFarlane wrote:
>
>
> The easiest approach would be to use a lua filter to
> modify the identifiers added by auto_identifiers.
> Then you don't need to modify the Haskell code.
>
> See the documentation on the website for lua filters.
> It would be a few lines.
>
> Mehran Baghi <1mehra...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <javascript:>> writes:
>
> > The auto_identifiers extension replaces all spaces to hyphens.
> >
> > https://pandoc.org/MANUAL.html#headings-and-sections
> >
> > I need it to replace them to underscores to keep my website urls
> uniform.
> > I have searched the github repo and couldn't find the extension file to
> fix
> > it myself.
> > Is it Extensions.hs ? How can I fix it?
> >
> > --
> > 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 post to this group, send email to pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
> <javascript:>.
> > To view this discussion on the web visit
> https://groups.google.com/d/msgid/pandoc-discuss/8f31ab60-ab45-4201-bac1-c420438b7b0a%40googlegroups.com.
>
> > For more options, visit https://groups.google.com/d/optout.
>
--
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/962ba188-1047-467d-9af6-6f0f30242aa1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
[-- Attachment #1.2: Type: text/html, Size: 4900 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: auto_identifiers (-) -> (_)
[not found] ` <962ba188-1047-467d-9af6-6f0f30242aa1-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2019-05-21 19:57 ` Albert Krewinkel
[not found] ` <87tvdnmvh6.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
2019-05-21 19:57 ` John MacFarlane
2019-05-22 0:25 ` Kolen Cheung
2 siblings, 1 reply; 10+ messages in thread
From: Albert Krewinkel @ 2019-05-21 19:57 UTC (permalink / raw)
To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw
Mehran Baghi writes:
> Thank you Dr. MacFarlane.
>
> The problem with writing a filter to replace (-)s to (_)s is you wouldn't
> know
> whether the hyphen was a space and auto_identifiers turned it to a hyphen,
> or it was a hyphen in the first place.
>
> Is there any other options?
> I don't know any haskell yet, but I guess in this case it would be as easy
> as
> changing a character (-) -> (_). I just don't know where to look.
One could go the opposite direction and use a Lua filter to create the
identifiers yourself. Below is an example that, for headers headers
"Hello, World" and "non-negotiable", creates identifiers "hello_world"
and "non-negotiable", respectively.
string.uc_lower = (require 'text').lower
function Header (h)
-- do nothing if the identifier is already set
if h.identifier ~= '' then return nil end
h.identifier = pandoc.utils.stringify(h)
:lower()
:gsub('[^%w%s%-]', '')
:gsub('%s', '_')
return h
end
See <https://www.lua.org/manual/5.3/manual.html#6.4.1> for more
information on pattern matching in Lua.
HTH,
Albert
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: auto_identifiers (-) -> (_)
[not found] ` <962ba188-1047-467d-9af6-6f0f30242aa1-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2019-05-21 19:57 ` Albert Krewinkel
@ 2019-05-21 19:57 ` John MacFarlane
2019-05-22 0:25 ` Kolen Cheung
2 siblings, 0 replies; 10+ messages in thread
From: John MacFarlane @ 2019-05-21 19:57 UTC (permalink / raw)
To: Mehran Baghi, pandoc-discuss
> The problem with writing a filter to replace (-)s to (_)s is you wouldn't
> know
> whether the hyphen was a space and auto_identifiers turned it to a hyphen,
> or it was a hyphen in the first place.
Well, then, you could disable auto_identifiers and
have the lua filter add the identifiers, based on
the heading contents, using a scheme of your own choosing.
In the lua filter, use pandoc.utils.stringify to
convert the heading contents to a string.
I don't want to discourage learning Haskell, but
maintaining your own fork of an open-source project
can be a pain. Easier to use filters.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: auto_identifiers (-) -> (_)
[not found] ` <962ba188-1047-467d-9af6-6f0f30242aa1-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2019-05-21 19:57 ` Albert Krewinkel
2019-05-21 19:57 ` John MacFarlane
@ 2019-05-22 0:25 ` Kolen Cheung
[not found] ` <36ff6fa9-1f16-4af9-906a-b10a070fffff-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2 siblings, 1 reply; 10+ messages in thread
From: Kolen Cheung @ 2019-05-22 0:25 UTC (permalink / raw)
To: pandoc-discuss
[-- Attachment #1: Type: text/plain, Size: 323 bytes --]
Why would you want to know that hyphen came from a space or an actual hyphen in the first place? It is supposed to be destructive (I.e. not one one one corresponding.)
And I agree if you want to have full control on the generation process, probably you should either write your own filter or program or write it manually.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: auto_identifiers (-) -> (_)
[not found] ` <87tvdnmvh6.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
@ 2019-06-03 6:49 ` Mehran Baghi
0 siblings, 0 replies; 10+ messages in thread
From: Mehran Baghi @ 2019-06-03 6:49 UTC (permalink / raw)
To: pandoc-discuss
[-- Attachment #1.1: Type: text/plain, Size: 1634 bytes --]
This worked perfectly. I don't know how to thank you Mr. Krewinkel.
I gave you credit in my code:
https://gitlab.com/hott_for_cools/book/blob/master/builder/auto_identifiers_underscore.lua
Thank you again. (and sorry for delayed reply)
On Wednesday, May 22, 2019 at 12:27:50 AM UTC+4:30, Albert Krewinkel wrote:
>
>
> One could go the opposite direction and use a Lua filter to create the
> identifiers yourself. Below is an example that, for headers headers
> "Hello, World" and "non-negotiable", creates identifiers "hello_world"
> and "non-negotiable", respectively.
>
> string.uc_lower = (require 'text').lower
>
> function Header (h)
> -- do nothing if the identifier is already set
> if h.identifier ~= '' then return nil end
>
> h.identifier = pandoc.utils.stringify(h)
> :lower()
> :gsub('[^%w%s%-]', '')
> :gsub('%s', '_')
> return h
> end
>
> See <https://www.lua.org/manual/5.3/manual.html#6.4.1> for more
> information on pattern matching in Lua.
>
> HTH,
>
> Albert
>
--
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/94ddcf07-093d-469c-9821-0cd3ae4cc2c6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
[-- Attachment #1.2: Type: text/html, Size: 2955 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: auto_identifiers (-) -> (_)
[not found] ` <36ff6fa9-1f16-4af9-906a-b10a070fffff-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2019-06-03 7:27 ` Mehran Baghi
[not found] ` <4f10048a-4a33-4951-a523-470a55d9a24e-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
0 siblings, 1 reply; 10+ messages in thread
From: Mehran Baghi @ 2019-06-03 7:27 UTC (permalink / raw)
To: pandoc-discuss
[-- Attachment #1.1: Type: text/plain, Size: 1357 bytes --]
Here is an example:
Sometimes hyphens have semantic significance:
"A well-fed pet" -> auto_identifiers -> a-well-fed-pet -> [ filter that
turns (-) into (_) ] -> a_well_fed_pet
While it should be "a_well-fed_pet"
Underlines are a better replacement for spaces. I wish that was the default
output of auto_identifiers.
Anyway, Albert's code above solves the problem.
On Wednesday, May 22, 2019 at 4:55:18 AM UTC+4:30, Kolen Cheung wrote:
>
> Why would you want to know that hyphen came from a space or an actual
> hyphen in the first place? It is supposed to be destructive (I.e. not one
> one one corresponding.)
>
> And I agree if you want to have full control on the generation process,
> probably you should either write your own filter or program or write it
> manually.
>
--
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/4f10048a-4a33-4951-a523-470a55d9a24e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
[-- Attachment #1.2: Type: text/html, Size: 2050 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: auto_identifiers (-) -> (_)
[not found] ` <4f10048a-4a33-4951-a523-470a55d9a24e-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2019-06-03 9:04 ` BPJ
[not found] ` <CADAJKhBrk5XiWWk-ihu2t1=kM8CfUB9mhxqNSGcceZXtwUVWnw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
0 siblings, 1 reply; 10+ messages in thread
From: BPJ @ 2019-06-03 9:04 UTC (permalink / raw)
To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw
[-- Attachment #1: Type: text/plain, Size: 3165 bytes --]
The English spelling conventions for when you write compound words with a
hyphen, with a space or with neither a hyphen nor a space are totally
arbitrary (you have to learn them on a word-by-word basis) and the
difference seldom affects meaning, and when it does affect meaning, e.g. in
_black bird_ vs. _blackbird_ the compound is usually written as one word.
Thus it hardly matters whether you use underscores or hyphens in
identifiers, and in most programming languages you have no choice: you have
to use underscores or write as one word. In TeX labels it is the other way
around: you have to use hyphens, and since Pandoc auto-identifiers need to
work as TeX labels hyphens is rightly the default. The reason hyphens are
the norm in HTML identifiers is probably that underscores are unfamiliar to
non-programmers, many of whom wouldn't even know how to type them.
Den mån 3 juni 2019 09:27Mehran Baghi <1mehranbaghi-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> skrev:
> Here is an example:
>
> Sometimes hyphens have semantic significance:
> "A well-fed pet" -> auto_identifiers -> a-well-fed-pet -> [ filter that
> turns (-) into (_) ] -> a_well_fed_pet
> While it should be "a_well-fed_pet"
>
> Underlines are a better replacement for spaces. I wish that was the default
> output of auto_identifiers.
>
> Anyway, Albert's code above solves the problem.
>
> On Wednesday, May 22, 2019 at 4:55:18 AM UTC+4:30, Kolen Cheung wrote:
>>
>> Why would you want to know that hyphen came from a space or an actual
>> hyphen in the first place? It is supposed to be destructive (I.e. not one
>> one one corresponding.)
>>
>> And I agree if you want to have full control on the generation process,
>> probably you should either write your own filter or program or write it
>> manually.
>>
> --
> 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/4f10048a-4a33-4951-a523-470a55d9a24e%40googlegroups.com
> <https://groups.google.com/d/msgid/pandoc-discuss/4f10048a-4a33-4951-a523-470a55d9a24e%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
--
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/CADAJKhBrk5XiWWk-ihu2t1%3DkM8CfUB9mhxqNSGcceZXtwUVWnw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
[-- Attachment #2: Type: text/html, Size: 4435 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: auto_identifiers (-) -> (_)
[not found] ` <CADAJKhBrk5XiWWk-ihu2t1=kM8CfUB9mhxqNSGcceZXtwUVWnw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2019-06-03 11:35 ` Mehran Baghi
0 siblings, 0 replies; 10+ messages in thread
From: Mehran Baghi @ 2019-06-03 11:35 UTC (permalink / raw)
To: pandoc-discuss
[-- Attachment #1.1: Type: text/plain, Size: 2232 bytes --]
> The English spelling conventions for when you write compound words with a
hyphen,
> with a space or with neither a hyphen nor a space are totally arbitrary
> (you have to learn them on a word-by-word basis) and the difference
seldom affects
> meaning, and when it does affect meaning, e.g. in _black bird_ vs.
_blackbird_
> the compound is usually written as one word.
I agree.
> Thus it hardly matters whether you use underscores or hyphens in
identifiers
I think underlines are a better replacement for spaces,
not just in identifiers, but also in URLs, filenames, etc.
Consider this wikipedia entry for "Claude-Louis Navier":
https://en.wikipedia.org/wiki/Claude-Louis_Navier
If wikipedia had chosen hyphens as a delimiter, it would have become:
https://en.wikipedia.org/wiki/Claude-Louis-Navier
I do prefer the first one and I'm not sure that this is just a matter of
taste.
> in most programming languages you have no choice: you have to
> use underscores or write as one word.
I'm not sure what you're referring to. (variable names?)
> In TeX labels it is the other way around: you have to use hyphens, and
since
> Pandoc auto-identifiers need to work as TeX labels hyphens is rightly the
default.
Yes, underscores in TeX labels can cause complications and there are
workarounds:
https://tex.stackexchange.com/questions/121416/putting-an-underscore-in-a-label
> The reason hyphens are the norm in HTML identifiers is probably that
underscores
> are unfamiliar to non-programmers, many of whom wouldn't even know how to
type them.
Are they? I don't know about that, wikipedia is an example of a
popular website using underscores.
--
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/76455998-ab5d-40e4-aaec-b4c28eb5c613%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
[-- Attachment #1.2: Type: text/html, Size: 3166 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2019-06-03 11:35 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-21 8:52 auto_identifiers (-) -> (_) Mehran Baghi
[not found] ` <8f31ab60-ab45-4201-bac1-c420438b7b0a-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2019-05-21 16:40 ` John MacFarlane
[not found] ` <m24l5nrc9z.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
2019-05-21 17:41 ` Mehran Baghi
[not found] ` <962ba188-1047-467d-9af6-6f0f30242aa1-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2019-05-21 19:57 ` Albert Krewinkel
[not found] ` <87tvdnmvh6.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
2019-06-03 6:49 ` Mehran Baghi
2019-05-21 19:57 ` John MacFarlane
2019-05-22 0:25 ` Kolen Cheung
[not found] ` <36ff6fa9-1f16-4af9-906a-b10a070fffff-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2019-06-03 7:27 ` Mehran Baghi
[not found] ` <4f10048a-4a33-4951-a523-470a55d9a24e-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2019-06-03 9:04 ` BPJ
[not found] ` <CADAJKhBrk5XiWWk-ihu2t1=kM8CfUB9mhxqNSGcceZXtwUVWnw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2019-06-03 11:35 ` Mehran Baghi
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).