> Don't use ChatGPT to "write code"! You will get garbage which may harm your computer and/or files if you run it!

I am sure It won't damage your computer. It will probably be not perfect, but with some common sense you will be safe.

On Monday, 8 May 2023 at 19:28:52 UTC+2 Mark Pinsley wrote:
Thank you!

Yeah ChatGPT isn't really very good at writing code unless you already know what you are doing. Then you can modify it. For me, I was trying to find a way to write this. Thank you!


On Mon, May 8, 2023 at 11:59 AM BPJ <mel...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
Don't use ChatGPT to "write code"! You will get garbage which may harm your computer and/or files if you run it!

This filter will do what you want:

``````lua
local str = pandoc.Str
local function quote (q)
  return pandoc.RawInline('markdown', q)
end
local quote_pat = re.compile(
  [[ {| ( [^"']+ -> str / ["'] -> quote )* |} ]],
  { str = str, quote = quote }
)
function Str (elem)
  return quote_pat:match(elem.text)
end
function Span (elem)
  if 1 == #elem.classes and 'mark' == elem.classes[1] then
    return elem.content
  end
  return nil
end
``````

/bpj

Den mån 8 maj 2023 00:09Mark Pinsley <ma...-NHpudssogepBDgjK7y7TUQ@public.gmane.org> skrev:
I have a bunch of docx that I want to convert to MD.

The file contains highlighting and it also contains both quotes and double quotes

For ease of someone being able to look at this MD, i want to remove the escape sequece for the quotes and double quotes.

I also want to remove the highlighting

ChatGPT wrote this LUA for me but it doesn't seem to work. Are there alternatives

function process_inlines(inlines)
    local result = {}
    for _, inline in ipairs(inlines) do
        if inline.t == "Str" then
            inline.text = inline.text:gsub('\\"', '"'):gsub("\\'", "'")
        elseif inline.content then
            inline.content = process_inlines(inline.content)
        end
        table.insert(result, inline)
    end
    return result
end

function process_blocks(blocks)
    local result = {}
    for _, block in ipairs(blocks) do
        if block.content then
            block.content = process_inlines(block.content)
        end
        table.insert(result, block)
    end
    return result
end

function Pandoc(doc)
    doc.blocks = process_blocks(doc.blocks)
    return doc
end

the command I used was:
 pandoc "TestHighlightQuotes.docx" --lua-filter remove_escaped_quotes.lua --wrap=none --reference-links -o output.md

Is there another way, or did I do something wrong?

--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/ef709575-3717-493f-b6d8-62862c98d3d8n%40googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "pandoc-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pandoc-discuss/dF3psW96pkA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CADAJKhA_g%3D6gfAJONkb3AwdQ9Xqn8PvwUg-fAVEjsKE56%2B%2BgFg%40mail.gmail.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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/bc3186fd-822a-40da-99d2-9454caeabb3en%40googlegroups.com.