public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* Lua filter to insert non-breable spaces
@ 2020-09-30 12:40 krulis....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
       [not found] ` <62329746-0b8e-41f1-93d9-042398687631n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 11+ messages in thread
From: krulis....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org @ 2020-09-30 12:40 UTC (permalink / raw)
  To: pandoc-discuss


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

I have the same situation as person asking here on discuss: 
<https://groups.google.com/g/pandoc-discuss/c/tZ2f51iLEIk/m/CSF_AWUXBQAJ>
I am trying to insert non-breakable spaces instead of specific Space 
elements in text. I tryed to work it out from example "Removing spaces 
before citations;" but I am probably using Inlines wrong.

I am asking this, because it seems that in the original question has no 
final answer/solution.

The filter I am using is as this:

```nonbreakableSpace.lua
function myCheckString(myString)
  if myString == 'a' or
  myString == 'i' then
    return true
  else
    return false
  end
end

function Inlines (inlines)
  for i = 1, #inlines do
    if inlines[i].t == 'Space' then
      if inlines[i - 1].t == 'Str' then
        local oneLetterPrefix = myCheckString(inlines[i - 1].c)
        if oneLetterPrefix == true then
          inlines[i - 1] = inlines[i - 1].c .. "\160" .. inlines[i + 1].c
          inlines:remove(i)
          inlines:remove(i + 1)
        end
      end
    end
  end
  return inlines
end
```

and very short test file:

```test.txt
a\ i test

a i test
```

Most probably it is evident that I am lua newbie. But the idea is to take 
list of Inlines, check every element if it is type Space, then check if 
previous element is Str, and then file check this strings contents, if it 
matches `myString` (names are horrible, I know). 

So the expected native pandoc out of the test is:

[Para [Str "a\160i\160test"]
Para [Str "a\160i\160test"]]

However, currently I am getting error:

nonbreakableSpace .lua:12: attempt to index a nil value (field '?')
stack traceback:
        pandocVlna.lua:12: in function 'Inlines'

How could I fix that?

Regards, Tomas

-- 
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/62329746-0b8e-41f1-93d9-042398687631n%40googlegroups.com.

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

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

* Re: Lua filter to insert non-breable spaces
       [not found] ` <62329746-0b8e-41f1-93d9-042398687631n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2020-09-30 13:32   ` Albert Krewinkel
       [not found]     ` <87k0wbjsov.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
  0 siblings, 1 reply; 11+ messages in thread
From: Albert Krewinkel @ 2020-09-30 13:32 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

Hi Tomas,

the error is caused by the assumption that `inlines[i]` always exists.
This is not the case here, as the script can remove elements from
`inlines`, immediately making it shorter. Since `#inlines` is evaluated
only once, before the loop runs the first time, the script will look for
elements which no longer exists.

You can avoid the hassle of dealing with this by switching to a
different method of inserting the nbsp: if the `Space` element is
*replaced* by element `pandoc.Str '\160'`, then the number of elements
in `inlines` will stay constant. This saves you of the hassle of keeping
track of indices.

HTH,

Albert


krulis....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org writes:

> I have the same situation as person asking here on discuss:
> <https://groups.google.com/g/pandoc-discuss/c/tZ2f51iLEIk/m/CSF_AWUXBQAJ>
> I am trying to insert non-breakable spaces instead of specific Space
> elements in text. I tryed to work it out from example "Removing spaces
> before citations;" but I am probably using Inlines wrong.
>
> I am asking this, because it seems that in the original question has no
> final answer/solution.
>
> The filter I am using is as this:
>
> ```nonbreakableSpace.lua
> function myCheckString(myString)
>   if myString == 'a' or
>   myString == 'i' then
>     return true
>   else
>     return false
>   end
> end
>
> function Inlines (inlines)
>   for i = 1, #inlines do
>     if inlines[i].t == 'Space' then
>       if inlines[i - 1].t == 'Str' then
>         local oneLetterPrefix = myCheckString(inlines[i - 1].c)
>         if oneLetterPrefix == true then
>           inlines[i - 1] = inlines[i - 1].c .. "\160" .. inlines[i + 1].c
>           inlines:remove(i)
>           inlines:remove(i + 1)
>         end
>       end
>     end
>   end
>   return inlines
> end
> ```
>
> and very short test file:
>
> ```test.txt
> a\ i test
>
> a i test
> ```
>
> Most probably it is evident that I am lua newbie. But the idea is to take
> list of Inlines, check every element if it is type Space, then check if
> previous element is Str, and then file check this strings contents, if it
> matches `myString` (names are horrible, I know).
>
> So the expected native pandoc out of the test is:
>
> [Para [Str "a\160i\160test"]
> Para [Str "a\160i\160test"]]
>
> However, currently I am getting error:
>
> nonbreakableSpace .lua:12: attempt to index a nil value (field '?')
> stack traceback:
>         pandocVlna.lua:12: in function 'Inlines'
>
> How could I fix that?
>
> Regards, Tomas


--
Albert Krewinkel
GPG: 8eed e3e2 e8c5 6f18 81fe  e836 388d c0b2 1f63 1124


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

* Re: Lua filter to insert non-breable spaces
       [not found]     ` <87k0wbjsov.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
@ 2020-09-30 14:10       ` krulis....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
       [not found]         ` <3d7b4797-4d83-44fd-a65c-d612ab07a6dfn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 11+ messages in thread
From: krulis....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org @ 2020-09-30 14:10 UTC (permalink / raw)
  To: pandoc-discuss


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

Thank you very much for your help Albert!
It put me on the right path indeed (I am not getting errors anymore), 
however, I would like to ask you for one more push - with this filter 
definition:

```nonbreakablespaces.lua
function myCheckString(myString)
  if myString == 'a' or
  myString == 'i' then
    return true
  else
    return false
  end
end

function Inlines (inlines)
  for i = 1, #inlines do
    if inlines[i].t == 'Space' then
      if inlines[i - 1].t == 'Str' then
        local oneLetterPrefix = myCheckString(inlines[i - 1].c)
        if oneLetterPrefix == true then
          inlines[i] = pandoc.Str '\160'
        end
      end
    end
  end
  return inlines
end
```

(I have removed the offending element removals and changed the line before 
all "`end`s" according to your suggestion).
Turn out, that I dont know how to change one element type to another. If I 
use this filter, I get in `native pandoc` something like:

[Para [Str "a\160i",Space,Str "test"]
,Para [Str "a",Str "\65533",Str "i",Str "\65533",Str "test"]]

I have tryed few escapings, or set the type and content separately like:

inlines[i].t = 'Str'
inlines[i].c = '\160'

but to no avail (no change in the native output).
I would like to ask you one more time for guidance (well, hopefully, 
afterwards I give myself a little break from lua).

Regards, Tomas

Dne středa 30. září 2020 v 15:32:59 UTC+2 uživatel Albert Krewinkel napsal:

> Hi Tomas,
>
> the error is caused by the assumption that `inlines[i]` always exists.
> This is not the case here, as the script can remove elements from
> `inlines`, immediately making it shorter. Since `#inlines` is evaluated
> only once, before the loop runs the first time, the script will look for
> elements which no longer exists.
>
> You can avoid the hassle of dealing with this by switching to a
> different method of inserting the nbsp: if the `Space` element is
> *replaced* by element `pandoc.Str '\160'`, then the number of elements
> in `inlines` will stay constant. This saves you of the hassle of keeping
> track of indices.
>
> HTH,
>
> Albert
>
>
> krulis....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org writes:
>
> > I have the same situation as person asking here on discuss:
> > <https://groups.google.com/g/pandoc-discuss/c/tZ2f51iLEIk/m/CSF_AWUXBQAJ
> >
> > I am trying to insert non-breakable spaces instead of specific Space
> > elements in text. I tryed to work it out from example "Removing spaces
> > before citations;" but I am probably using Inlines wrong.
> >
> > I am asking this, because it seems that in the original question has no
> > final answer/solution.
> >
> > The filter I am using is as this:
> >
> > ```nonbreakableSpace.lua
> > function myCheckString(myString)
> > if myString == 'a' or
> > myString == 'i' then
> > return true
> > else
> > return false
> > end
> > end
> >
> > function Inlines (inlines)
> > for i = 1, #inlines do
> > if inlines[i].t == 'Space' then
> > if inlines[i - 1].t == 'Str' then
> > local oneLetterPrefix = myCheckString(inlines[i - 1].c)
> > if oneLetterPrefix == true then
> > inlines[i - 1] = inlines[i - 1].c .. "\160" .. inlines[i + 1].c
> > inlines:remove(i)
> > inlines:remove(i + 1)
> > end
> > end
> > end
> > end
> > return inlines
> > end
> > ```
> >
> > and very short test file:
> >
> > ```test.txt
> > a\ i test
> >
> > a i test
> > ```
> >
> > Most probably it is evident that I am lua newbie. But the idea is to take
> > list of Inlines, check every element if it is type Space, then check if
> > previous element is Str, and then file check this strings contents, if it
> > matches `myString` (names are horrible, I know).
> >
> > So the expected native pandoc out of the test is:
> >
> > [Para [Str "a\160i\160test"]
> > Para [Str "a\160i\160test"]]
> >
> > However, currently I am getting error:
> >
> > nonbreakableSpace .lua:12: attempt to index a nil value (field '?')
> > stack traceback:
> > pandocVlna.lua:12: in function 'Inlines'
> >
> > How could I fix that?
> >
> > Regards, Tomas
>
>
> --
> Albert Krewinkel
> GPG: 8eed e3e2 e8c5 6f18 81fe e836 388d c0b2 1f63 1124
>

-- 
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/3d7b4797-4d83-44fd-a65c-d612ab07a6dfn%40googlegroups.com.

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

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

* Re: Lua filter to insert non-breable spaces
       [not found]         ` <3d7b4797-4d83-44fd-a65c-d612ab07a6dfn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2020-09-30 14:29           ` Albert Krewinkel
       [not found]             ` <87imbvjq1p.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
  0 siblings, 1 reply; 11+ messages in thread
From: Albert Krewinkel @ 2020-09-30 14:29 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

Good to hear that things are (mostly) working!

krulis....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org writes:

> Turn out, that I dont know how to change one element type to another. If I
> use this filter, I get in `native pandoc` something like:
>
> [Para [Str "a\160i",Space,Str "test"]
> ,Para [Str "a",Str "\65533",Str "i",Str "\65533",Str "test"]]
>
> I have tryed few escapings, or set the type and content separately like:
>
> inlines[i].t = 'Str'
> inlines[i].c = '\160'
>
> but to no avail (no change in the native output).
> I would like to ask you one more time for guidance (well, hopefully,
> afterwards I give myself a little break from lua).

Right, I had missed that. Lua doesn't understand Haskell's syntax for
(Unicode) characters. We have to either use a literal nbsp character
' ' or give the byte-wise UTF-8 representation of that char: '\xc2\xa0'

Cheers!


--
Albert Krewinkel
GPG: 8eed e3e2 e8c5 6f18 81fe  e836 388d c0b2 1f63 1124

-- 
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/87imbvjq1p.fsf%40zeitkraut.de.


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

* Re: Lua filter to insert non-breable spaces
       [not found]             ` <87imbvjq1p.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
@ 2020-09-30 14:41               ` BPJ
       [not found]                 ` <CADAJKhDgxv6fYrNrxog5ZkJdai16SpFnJiOFZ8RtLhReQDoghA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  2020-09-30 14:42               ` krulis....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
  1 sibling, 1 reply; 11+ messages in thread
From: BPJ @ 2020-09-30 14:41 UTC (permalink / raw)
  To: pandoc-discuss

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

In Lua 5.3 you *can* embed arbitrary UTF-8 characters in strings quite
easily: "\u{a0}" will give you a string containing the no break space.


-- 
Better --help|less than helpless

Den ons 30 sep. 2020 16:30Albert Krewinkel <albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
skrev:

> Good to hear that things are (mostly) working!
>
> krulis....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org writes:
>
> > Turn out, that I dont know how to change one element type to another. If
> I
> > use this filter, I get in `native pandoc` something like:
> >
> > [Para [Str "a\160i",Space,Str "test"]
> > ,Para [Str "a",Str "\65533",Str "i",Str "\65533",Str "test"]]
> >
> > I have tryed few escapings, or set the type and content separately like:
> >
> > inlines[i].t = 'Str'
> > inlines[i].c = '\160'
> >
> > but to no avail (no change in the native output).
> > I would like to ask you one more time for guidance (well, hopefully,
> > afterwards I give myself a little break from lua).
>
> Right, I had missed that. Lua doesn't understand Haskell's syntax for
> (Unicode) characters. We have to either use a literal nbsp character
> ' ' or give the byte-wise UTF-8 representation of that char: '\xc2\xa0'
>
> Cheers!
>
>
> --
> Albert Krewinkel
> GPG: 8eed e3e2 e8c5 6f18 81fe  e836 388d c0b2 1f63 1124
>
> --
> 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/87imbvjq1p.fsf%40zeitkraut.de
> .
>

-- 
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/CADAJKhDgxv6fYrNrxog5ZkJdai16SpFnJiOFZ8RtLhReQDoghA%40mail.gmail.com.

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

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

* Re: Lua filter to insert non-breable spaces
       [not found]             ` <87imbvjq1p.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
  2020-09-30 14:41               ` BPJ
@ 2020-09-30 14:42               ` krulis....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
       [not found]                 ` <2e4fe1e0-39ce-438f-b2ec-fc57fd72cad0n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  1 sibling, 1 reply; 11+ messages in thread
From: krulis....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org @ 2020-09-30 14:42 UTC (permalink / raw)
  To: pandoc-discuss


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

Thank you very much, now everything works perfectly!
I have to learn about Unicode and UTF-8 representations, since my main 
language (czech) uses them pretty heavily.

I try to test and clean up the code a little (add more checks in 
`myCheckString` and do some renaming) and try to provide solution for some 
funny situations (test file kinda shows that:

source:

```
a\ i test
```

compiles to native

[Para [Str "a\160i",Space,Str "test"]

But the correct solution should be 

[Para [Str "a\160i",Str "\160",Str "test"] 

I try to fix that.)

However, since you have helped me a lot in creating this filter, and since 
I would take that as a "filter-quality assurence," I would like to offer 
this filter to be inluded in pandoc-lua-filters repository.
Would it be ok?

Regards, Tomas

Dne středa 30. září 2020 v 16:30:05 UTC+2 uživatel Albert Krewinkel napsal:

> Good to hear that things are (mostly) working!
>
> krulis....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org writes:
>
> > Turn out, that I dont know how to change one element type to another. If 
> I
> > use this filter, I get in `native pandoc` something like:
> >
> > [Para [Str "a\160i",Space,Str "test"]
> > ,Para [Str "a",Str "\65533",Str "i",Str "\65533",Str "test"]]
> >
> > I have tryed few escapings, or set the type and content separately like:
> >
> > inlines[i].t = 'Str'
> > inlines[i].c = '\160'
> >
> > but to no avail (no change in the native output).
> > I would like to ask you one more time for guidance (well, hopefully,
> > afterwards I give myself a little break from lua).
>
> Right, I had missed that. Lua doesn't understand Haskell's syntax for
> (Unicode) characters. We have to either use a literal nbsp character
> ' ' or give the byte-wise UTF-8 representation of that char: '\xc2\xa0'
>
> Cheers!
>
>
> --
> Albert Krewinkel
> GPG: 8eed e3e2 e8c5 6f18 81fe e836 388d c0b2 1f63 1124
>

-- 
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/2e4fe1e0-39ce-438f-b2ec-fc57fd72cad0n%40googlegroups.com.

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

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

* Re: Lua filter to insert non-breable spaces
       [not found]                 ` <CADAJKhDgxv6fYrNrxog5ZkJdai16SpFnJiOFZ8RtLhReQDoghA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2020-09-30 14:44                   ` Albert Krewinkel
  0 siblings, 0 replies; 11+ messages in thread
From: Albert Krewinkel @ 2020-09-30 14:44 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw


BPJ writes:

> In Lua 5.3 you *can* embed arbitrary UTF-8 characters in strings quite
> easily: "\u{a0}" will give you a string containing the no break space.

Oooooh, nice! Thanks!


-- 
Albert Krewinkel
GPG: 8eed e3e2 e8c5 6f18 81fe  e836 388d c0b2 1f63 1124


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

* Re: Lua filter to insert non-breable spaces
       [not found]                 ` <2e4fe1e0-39ce-438f-b2ec-fc57fd72cad0n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2020-09-30 14:46                   ` krulis....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
       [not found]                     ` <25ebada0-19c5-4ec4-a282-274308ee6b74n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 11+ messages in thread
From: krulis....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org @ 2020-09-30 14:46 UTC (permalink / raw)
  To: pandoc-discuss


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

Thank you @BP , your solution works great too.
Now I can even choose from two correct </nbsp> representations ... !

Dne středa 30. září 2020 v 16:42:02 UTC+2 uživatel krulis....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org 
napsal:

> Thank you very much, now everything works perfectly!
> I have to learn about Unicode and UTF-8 representations, since my main 
> language (czech) uses them pretty heavily.
>
> I try to test and clean up the code a little (add more checks in 
> `myCheckString` and do some renaming) and try to provide solution for some 
> funny situations (test file kinda shows that:
>
> source:
>
> ```
> a\ i test
> ```
>
> compiles to native
>
> [Para [Str "a\160i",Space,Str "test"]
>
> But the correct solution should be 
>
> [Para [Str "a\160i",Str "\160",Str "test"] 
>
> I try to fix that.)
>
> However, since you have helped me a lot in creating this filter, and since 
> I would take that as a "filter-quality assurence," I would like to offer 
> this filter to be inluded in pandoc-lua-filters repository.
> Would it be ok?
>
> Regards, Tomas
>
> Dne středa 30. září 2020 v 16:30:05 UTC+2 uživatel Albert Krewinkel napsal:
>
>> Good to hear that things are (mostly) working! 
>>
>> krulis....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org writes: 
>>
>> > Turn out, that I dont know how to change one element type to another. 
>> If I 
>> > use this filter, I get in `native pandoc` something like: 
>> > 
>> > [Para [Str "a\160i",Space,Str "test"] 
>> > ,Para [Str "a",Str "\65533",Str "i",Str "\65533",Str "test"]] 
>> > 
>> > I have tryed few escapings, or set the type and content separately 
>> like: 
>> > 
>> > inlines[i].t = 'Str' 
>> > inlines[i].c = '\160' 
>> > 
>> > but to no avail (no change in the native output). 
>> > I would like to ask you one more time for guidance (well, hopefully, 
>> > afterwards I give myself a little break from lua). 
>>
>> Right, I had missed that. Lua doesn't understand Haskell's syntax for 
>> (Unicode) characters. We have to either use a literal nbsp character 
>> ' ' or give the byte-wise UTF-8 representation of that char: '\xc2\xa0' 
>>
>> Cheers! 
>>
>>
>> -- 
>> Albert Krewinkel 
>> GPG: 8eed e3e2 e8c5 6f18 81fe e836 388d c0b2 1f63 1124 
>>
>

-- 
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/25ebada0-19c5-4ec4-a282-274308ee6b74n%40googlegroups.com.

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

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

* Re: Lua filter to insert non-breable spaces
       [not found]                     ` <25ebada0-19c5-4ec4-a282-274308ee6b74n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2020-09-30 14:49                       ` krulis....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
       [not found]                         ` <e83f7a58-5718-4858-b536-e7b95de540a9n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 11+ messages in thread
From: krulis....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org @ 2020-09-30 14:49 UTC (permalink / raw)
  To: pandoc-discuss


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

@BP I am still working on that other filter which should read path from 
metadata blocks; well, that one will take lot longer than this :)

If you are aware of LaTeX's `glossaries` package, final goal is to provide 
similar functions to `pandoc` ...

Dne středa 30. září 2020 v 16:46:36 UTC+2 uživatel krulis....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org 
napsal:

> Thank you @BP , your solution works great too.
> Now I can even choose from two correct </nbsp> representations ... !
>
> Dne středa 30. září 2020 v 16:42:02 UTC+2 uživatel krulis....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org 
> napsal:
>
>> Thank you very much, now everything works perfectly!
>> I have to learn about Unicode and UTF-8 representations, since my main 
>> language (czech) uses them pretty heavily.
>>
>> I try to test and clean up the code a little (add more checks in 
>> `myCheckString` and do some renaming) and try to provide solution for some 
>> funny situations (test file kinda shows that:
>>
>> source:
>>
>> ```
>> a\ i test
>> ```
>>
>> compiles to native
>>
>> [Para [Str "a\160i",Space,Str "test"]
>>
>> But the correct solution should be 
>>
>> [Para [Str "a\160i",Str "\160",Str "test"] 
>>
>> I try to fix that.)
>>
>> However, since you have helped me a lot in creating this filter, and 
>> since I would take that as a "filter-quality assurence," I would like to 
>> offer this filter to be inluded in pandoc-lua-filters repository.
>> Would it be ok?
>>
>> Regards, Tomas
>>
>> Dne středa 30. září 2020 v 16:30:05 UTC+2 uživatel Albert Krewinkel 
>> napsal:
>>
>>> Good to hear that things are (mostly) working! 
>>>
>>> krulis....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org writes: 
>>>
>>> > Turn out, that I dont know how to change one element type to another. 
>>> If I 
>>> > use this filter, I get in `native pandoc` something like: 
>>> > 
>>> > [Para [Str "a\160i",Space,Str "test"] 
>>> > ,Para [Str "a",Str "\65533",Str "i",Str "\65533",Str "test"]] 
>>> > 
>>> > I have tryed few escapings, or set the type and content separately 
>>> like: 
>>> > 
>>> > inlines[i].t = 'Str' 
>>> > inlines[i].c = '\160' 
>>> > 
>>> > but to no avail (no change in the native output). 
>>> > I would like to ask you one more time for guidance (well, hopefully, 
>>> > afterwards I give myself a little break from lua). 
>>>
>>> Right, I had missed that. Lua doesn't understand Haskell's syntax for 
>>> (Unicode) characters. We have to either use a literal nbsp character 
>>> ' ' or give the byte-wise UTF-8 representation of that char: '\xc2\xa0' 
>>>
>>> Cheers! 
>>>
>>>
>>> -- 
>>> Albert Krewinkel 
>>> GPG: 8eed e3e2 e8c5 6f18 81fe e836 388d c0b2 1f63 1124 
>>>
>>

-- 
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/e83f7a58-5718-4858-b536-e7b95de540a9n%40googlegroups.com.

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

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

* Re: Lua filter to insert non-breable spaces
       [not found]                         ` <e83f7a58-5718-4858-b536-e7b95de540a9n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2020-09-30 15:09                           ` BPJ
       [not found]                             ` <CADAJKhDh2zaKmuRKQYXRrf7MNOHrp-LkEEx2qoeV=oYPKb_Dzg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 11+ messages in thread
From: BPJ @ 2020-09-30 15:09 UTC (permalink / raw)
  To: pandoc-discuss

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

I'm working on a solution for that. :-) I had a molar extracted yesterday
and I have work to do, so it will be a while. If you haven't heard from me
after the weekend please ping me again.

-- 
Better --help|less than helpless

Den ons 30 sep. 2020 16:50krulis....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <krulis.tomas.tk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
skrev:

> @BP I am still working on that other filter which should read path from
> metadata blocks; well, that one will take lot longer than this :)
>
> If you are aware of LaTeX's `glossaries` package, final goal is to provide
> similar functions to `pandoc` ...
>
> Dne středa 30. září 2020 v 16:46:36 UTC+2 uživatel krulis....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
> napsal:
>
>> Thank you @BP , your solution works great too.
>> Now I can even choose from two correct </nbsp> representations ... !
>>
>> Dne středa 30. září 2020 v 16:42:02 UTC+2 uživatel krulis....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
>> napsal:
>>
>>> Thank you very much, now everything works perfectly!
>>> I have to learn about Unicode and UTF-8 representations, since my main
>>> language (czech) uses them pretty heavily.
>>>
>>> I try to test and clean up the code a little (add more checks in
>>> `myCheckString` and do some renaming) and try to provide solution for some
>>> funny situations (test file kinda shows that:
>>>
>>> source:
>>>
>>> ```
>>> a\ i test
>>> ```
>>>
>>> compiles to native
>>>
>>> [Para [Str "a\160i",Space,Str "test"]
>>>
>>> But the correct solution should be
>>>
>>> [Para [Str "a\160i",Str "\160",Str "test"]
>>>
>>> I try to fix that.)
>>>
>>> However, since you have helped me a lot in creating this filter, and
>>> since I would take that as a "filter-quality assurence," I would like to
>>> offer this filter to be inluded in pandoc-lua-filters repository.
>>> Would it be ok?
>>>
>>> Regards, Tomas
>>>
>>> Dne středa 30. září 2020 v 16:30:05 UTC+2 uživatel Albert Krewinkel
>>> napsal:
>>>
>>>> Good to hear that things are (mostly) working!
>>>>
>>>> krulis....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org writes:
>>>>
>>>> > Turn out, that I dont know how to change one element type to another.
>>>> If I
>>>> > use this filter, I get in `native pandoc` something like:
>>>> >
>>>> > [Para [Str "a\160i",Space,Str "test"]
>>>> > ,Para [Str "a",Str "\65533",Str "i",Str "\65533",Str "test"]]
>>>> >
>>>> > I have tryed few escapings, or set the type and content separately
>>>> like:
>>>> >
>>>> > inlines[i].t = 'Str'
>>>> > inlines[i].c = '\160'
>>>> >
>>>> > but to no avail (no change in the native output).
>>>> > I would like to ask you one more time for guidance (well, hopefully,
>>>> > afterwards I give myself a little break from lua).
>>>>
>>>> Right, I had missed that. Lua doesn't understand Haskell's syntax for
>>>> (Unicode) characters. We have to either use a literal nbsp character
>>>> ' ' or give the byte-wise UTF-8 representation of that char: '\xc2\xa0'
>>>>
>>>> Cheers!
>>>>
>>>>
>>>> --
>>>> Albert Krewinkel
>>>> GPG: 8eed e3e2 e8c5 6f18 81fe e836 388d c0b2 1f63 1124
>>>>
>>> --
> 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/e83f7a58-5718-4858-b536-e7b95de540a9n%40googlegroups.com
> <https://groups.google.com/d/msgid/pandoc-discuss/e83f7a58-5718-4858-b536-e7b95de540a9n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CADAJKhDh2zaKmuRKQYXRrf7MNOHrp-LkEEx2qoeV%3DoYPKb_Dzg%40mail.gmail.com.

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

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

* Re: Lua filter to insert non-breable spaces
       [not found]                             ` <CADAJKhDh2zaKmuRKQYXRrf7MNOHrp-LkEEx2qoeV=oYPKb_Dzg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2020-09-30 15:13                               ` krulis....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
  0 siblings, 0 replies; 11+ messages in thread
From: krulis....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org @ 2020-09-30 15:13 UTC (permalink / raw)
  To: pandoc-discuss


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

Those are wonderfull news!

Will do.

Thank you for your time.

Regards, Tomas

Dne středa 30. září 2020 v 17:10:01 UTC+2 uživatel BP napsal:

> I'm working on a solution for that. :-) I had a molar extracted yesterday 
> and I have work to do, so it will be a while. If you haven't heard from me 
> after the weekend please ping me again.
>
> -- 
> Better --help|less than helpless
> Den ons 30 sep. 2020 16:50krulis....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <krulis....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 
> skrev:
>
>> @BP I am still working on that other filter which should read path from 
>> metadata blocks; well, that one will take lot longer than this :)
>>
>> If you are aware of LaTeX's `glossaries` package, final goal is to 
>> provide similar functions to `pandoc` ...
>>
>> Dne středa 30. září 2020 v 16:46:36 UTC+2 uživatel krulis....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org 
>> napsal:
>>
>>> Thank you @BP , your solution works great too.
>>> Now I can even choose from two correct </nbsp> representations ... !
>>>
>>> Dne středa 30. září 2020 v 16:42:02 UTC+2 uživatel krulis....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org 
>>> napsal:
>>>
>>>> Thank you very much, now everything works perfectly!
>>>> I have to learn about Unicode and UTF-8 representations, since my main 
>>>> language (czech) uses them pretty heavily.
>>>>
>>>> I try to test and clean up the code a little (add more checks in 
>>>> `myCheckString` and do some renaming) and try to provide solution for some 
>>>> funny situations (test file kinda shows that:
>>>>
>>>> source:
>>>>
>>>> ```
>>>> a\ i test
>>>> ```
>>>>
>>>> compiles to native
>>>>
>>>> [Para [Str "a\160i",Space,Str "test"]
>>>>
>>>> But the correct solution should be 
>>>>
>>>> [Para [Str "a\160i",Str "\160",Str "test"] 
>>>>
>>>> I try to fix that.)
>>>>
>>>> However, since you have helped me a lot in creating this filter, and 
>>>> since I would take that as a "filter-quality assurence," I would like to 
>>>> offer this filter to be inluded in pandoc-lua-filters repository.
>>>> Would it be ok?
>>>>
>>>> Regards, Tomas
>>>>
>>>> Dne středa 30. září 2020 v 16:30:05 UTC+2 uživatel Albert Krewinkel 
>>>> napsal:
>>>>
>>>>> Good to hear that things are (mostly) working! 
>>>>>
>>>>> krulis....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org writes: 
>>>>>
>>>>> > Turn out, that I dont know how to change one element type to 
>>>>> another. If I 
>>>>> > use this filter, I get in `native pandoc` something like: 
>>>>> > 
>>>>> > [Para [Str "a\160i",Space,Str "test"] 
>>>>> > ,Para [Str "a",Str "\65533",Str "i",Str "\65533",Str "test"]] 
>>>>> > 
>>>>> > I have tryed few escapings, or set the type and content separately 
>>>>> like: 
>>>>> > 
>>>>> > inlines[i].t = 'Str' 
>>>>> > inlines[i].c = '\160' 
>>>>> > 
>>>>> > but to no avail (no change in the native output). 
>>>>> > I would like to ask you one more time for guidance (well, hopefully, 
>>>>> > afterwards I give myself a little break from lua). 
>>>>>
>>>>> Right, I had missed that. Lua doesn't understand Haskell's syntax for 
>>>>> (Unicode) characters. We have to either use a literal nbsp character 
>>>>> ' ' or give the byte-wise UTF-8 representation of that char: 
>>>>> '\xc2\xa0' 
>>>>>
>>>>> Cheers! 
>>>>>
>>>>>
>>>>> -- 
>>>>> Albert Krewinkel 
>>>>> GPG: 8eed e3e2 e8c5 6f18 81fe e836 388d c0b2 1f63 1124 
>>>>>
>>>> -- 
>>
> 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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>>
> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/pandoc-discuss/e83f7a58-5718-4858-b536-e7b95de540a9n%40googlegroups.com 
>> <https://groups.google.com/d/msgid/pandoc-discuss/e83f7a58-5718-4858-b536-e7b95de540a9n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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/acecda16-be9e-4df6-8483-63d1d433a344n%40googlegroups.com.

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

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

end of thread, other threads:[~2020-09-30 15:13 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-30 12:40 Lua filter to insert non-breable spaces krulis....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
     [not found] ` <62329746-0b8e-41f1-93d9-042398687631n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-09-30 13:32   ` Albert Krewinkel
     [not found]     ` <87k0wbjsov.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
2020-09-30 14:10       ` krulis....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
     [not found]         ` <3d7b4797-4d83-44fd-a65c-d612ab07a6dfn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-09-30 14:29           ` Albert Krewinkel
     [not found]             ` <87imbvjq1p.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
2020-09-30 14:41               ` BPJ
     [not found]                 ` <CADAJKhDgxv6fYrNrxog5ZkJdai16SpFnJiOFZ8RtLhReQDoghA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2020-09-30 14:44                   ` Albert Krewinkel
2020-09-30 14:42               ` krulis....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
     [not found]                 ` <2e4fe1e0-39ce-438f-b2ec-fc57fd72cad0n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-09-30 14:46                   ` krulis....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
     [not found]                     ` <25ebada0-19c5-4ec4-a282-274308ee6b74n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-09-30 14:49                       ` krulis....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
     [not found]                         ` <e83f7a58-5718-4858-b536-e7b95de540a9n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-09-30 15:09                           ` BPJ
     [not found]                             ` <CADAJKhDh2zaKmuRKQYXRrf7MNOHrp-LkEEx2qoeV=oYPKb_Dzg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2020-09-30 15:13                               ` krulis....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

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