Git Product home page Git Product logo

Comments (7)

charles2910 avatar charles2910 commented on June 19, 2024 1

we (sergiodj, samueloph and I) are suspecting the problem is in echo (which is a built in commad), not actually in sed. I'll try to do a debug session during the weekend to pinpoint the issue and report upstream. I thought "maybe I should try to report this quick and dirty fix before", but I see it might be a problem to other systems.

from kristall.

MasterQ32 avatar MasterQ32 commented on June 19, 2024

This is actually a good question, i think we actually switched from bash to sh as it wasn't compatible to other systems. is sed a shell builtin in dash?

from kristall.

charles2910 avatar charles2910 commented on June 19, 2024

Ok, I was able to pinpoint the problem:
image

Double escaping seems to solve it in sh/dash, but it put 2 backslashs in bash. I'm not sure what is the correct/expected behavior in this case.

sh/dash:

$ echo $(echo press *Return* and | sed -E -e 's#(^|[.,!? ]+)[*_]([^*_ ]+[^*_]+[^*_ ]+)[*_]($|[.,!? ])#\1\\\\fI\2\\\\fR\3#g')
press \fIReturn\fR and

bash:

charles@x1-carbon:~$ echo $(echo press *Return* and | sed -E -e 's#(^|[.,!? ]+)[*_]([^*_ ]+[^*_]+[^*_ ]+)[*_]($|[.,!? ])#\1\\\\fI\2\\\\fR\3#g')
press \\fIReturn\\fR and

from kristall.

charles2910 avatar charles2910 commented on June 19, 2024

Now I think I've found the answer. sh and, consequently, dash interpret some escaped characters as control sequences, so an echo '\f' outputs a form feed. bash's echo defaults to ignore escaped characters unless explicitly told otherwise (-e flag).

So, my question is: should we double escape \f to comply with dash? If you agree, I can open a PR with this fix:

diff --git a/doc/gen-man.sh b/doc/gen-man.sh
index 4463c5a..52b5132 100755
--- a/doc/gen-man.sh
+++ b/doc/gen-man.sh
@@ -59,8 +59,8 @@ gem_in=$(
     # First expression replaces all [Text like this] with bold text.
     # Second expression replaces text like *This* or _this_ with italic text.
     sed -E \
-      -e 's#\[([^]]*)\]#\\fB\1\\fR#g' \
-      -e 's#(^|[.,!? ]+)[*_]([^*_ ]+[^*_]+[^*_ ]+)[*_]($|[.,!? ])#\1\\fI\2\\fR\3#g'
+      -e 's#\[([^]]*)\]#\\\\fB\1\\\\fR#g' \
+      -e 's#(^|[.,!? ]+)[*_]([^*_ ]+[^*_]+[^*_ ]+)[*_]($|[.,!? ])#\1\\\\fI\2\\\\fR\3#g'
 )
 
 # Convert gemtext to man format

from kristall.

MasterQ32 avatar MasterQ32 commented on June 19, 2024

Yeah, can you try make a PR?

from kristall.

charles2910 avatar charles2910 commented on June 19, 2024

Yeah, of course!

from kristall.

charles2910 avatar charles2910 commented on June 19, 2024

I think we can close this issue, right?

from kristall.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.