funkydan2 / hugo-kiera

Kiera - A Hugo Theme for writing
https://hugo-kiera.netlify.app
MIT License
71 stars 53 forks source link

add invisible char filter #58

Closed lau-jay closed 3 years ago

lau-jay commented 3 years ago

if markdown exists invisible char, will get below error

This page contains the following errors:
error on line 1595 at column 43: PCDATA invalid Char value 8
Below is a rendering of the page up to the first error.

so, I want to add replaceRE method filter all invisible char for raw markdown content. I'm a re newbie, if you have a good idea, pls tell me.

lau-jay commented 3 years ago

wait a moment, I need a bugfix

funkydan2 commented 3 years ago

Hi @lau-jay,

This partial is based on https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/_default/rss.xml. I can see there's be a few changes to the default HUGO template - maybe we should incorporate them as well.

I'm trying to remember what the | html does. I can't see anything about it in the hugo documentation. Maybe .content should be piped through markdownify? Do you want to test and see if that gives the result you're looking for?

lau-jay commented 3 years ago

sure, I will try it

lau-jay commented 3 years ago

HI @funkydan2, I try it on my local env. It doesn't work for me. but yes, we should incorporate them as well. And piped through markdownify not work. I think maybe replaceRE will fix it, but RE is so difficult, I think maybe need to do more work on this problem.

funkydan2 commented 3 years ago

So what character is causing the problem?

This thread on Stack Overflow suggests the problem is unescaped characters in XML. Can you test what happens if you replace the html function with htmlEscape (https://gohugo.io/functions/htmlescape/#readout)?

lau-jay commented 3 years ago

well, it's all try. I find what problem character, I try to replace all control using [:cntrl:] but it does not work... I read the document again..

[[:cntrl:]] | control (≡ [\x00-\x1F\x7F])

I think copy [\x00-\x1F\x7F] to replaceRE argument. done...it's work for me.