This filter will convert all raw HTML to code in backticks, with syntax highlighting. Save it as raw2code.lua and include --lua-filter=raw2code.lua on the pandoc command line.

local code_for = {
  RawInline = pandoc.Code,
  RawBlock = pandoc.CodeBlock
}
local function raw2code (elem)
  if 'html' == elem.format then
    return code_for[elem.tag](elem.text, { class = 'html' })
  end
  return nil
end
return {
  {
    RawInline = raw2code,
    RawBlock = raw2code
  }
}






Den tors 10 feb. 2022 14:24William Lupton <wlupton@broadband-forum.org> skrev:
If you simply want to ignore all raw HTML elements then I think that a lua filter that ignores all RawInlines (perhaps only those with format="html") will work for you. But if some HTML elements need to retain their HTML meaning then more logic will be needed. For example, this document:

% cat raw.md
This is <b>bold</b> text.

gives this HTML:

% pandoc raw.md
<p>This is <b>bold</b> text.</p>


...but with this filter:

% cat raw.lua
function RawInline(raw)
  if (raw.format == 'html') then
    return {}
  end
end


...it gives this:

% pandoc raw.md -L raw.lua
<p>This is bold text.</p>





On Thu, 10 Feb 2022 at 12:49, mr vicky <v.lonly007-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
so before convert to epub file i have to edit md file and find all tags and add these backticks ?
there is no option in pandoc to ignore tags inside book ?

On Thursday, February 10, 2022 at 5:37:27 PM UTC+5 Joost wrote:
On Thu, 10 Feb 2022, at 11:27, mr vicky wrote:
> hello
> i am converting md to epub file but that md file is programming book
> where is some codes written inside but when i convert it to epub then
> its auto detecting these tags and making very bad epub file with page
> breaks and some other kind of coding elements
[...]
> there is any option to ignore programming codes while converting to epub file ?

Note that Markdown allows you to include HTML elements, so whenever you write e.g. <h1> directly, Pandoc assums that's what you're doing and will put an <h1> tag in the html (or epub) output.

You'll want to mark the tags as code, which you can do with backticks: `<h1>`.

HTH

--
Joost Kremers
Life has its moments

--
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-/JYPxA39Uh4Ykp1iOSErHA@public.gmane.orgm.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/3806ef68-3553-4e8e-8b04-bf7cc4226e7cn%40googlegroups.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-/JYPxA39Uh4Ykp1iOSErHA@public.gmane.orgm.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CAEe_xxjC3As4wO0e4uz6PtVzakK7jaC89rUKKb_BiUwHpbh%3D7Q%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/CADAJKhDhA7kP2JfM9tXDc%3DpmmjP7BA5dGgnVE2T%3D2b1dmF3MFw%40mail.gmail.com.