File: relnotes_to_cstring.sed

package info (click to toggle)
utox 0.18.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 10,792 kB
  • sloc: ansic: 102,804; objc: 2,385; cpp: 2,069; java: 1,094; python: 868; javascript: 703; xml: 424; sh: 208; makefile: 53; sed: 9
file content (29 lines) | stat: -rwxr-xr-x 578 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/sed -f

# This is a helper script to convert release notes written in Markdown
# to C-strings for langs/*.h
# This is not supposed to be perfect.

# (@user)
s/(@\([^)]*\))/(Thanks, \1!)/
# (commit)
s/ ([ 0-9a-f]\+)//

# escape "
s/"/\\"/g

# ## (Features:) → "  \1\n"
s/^## \(.*\)$/"  \1\\n"/

# * (Fix …)      → "    \1\n"
s/^* \(.*\)$/"    \1\\n"/

# (-…)           → "      \1\n"
s/^[[:space:]]\+\(-.*\)$/"      \1\\n"/

# **(…)**        → "  \1\n" [important notes]
s/^\*\*\(.*\)\*\*$/"  \1\\n"/

# c-string the rest
s/^\([^"].*\)$/"\1\\n"/
s/^$/"\\n"/