add markdown newlines option (#552)

This commit is contained in:
ed 2025-08-23 22:29:41 +00:00
parent 8f235be66f
commit 0491123bb2
9 changed files with 14 additions and 7 deletions

View file

@ -1634,6 +1634,7 @@ def add_db_metadata(ap):
def add_txt(ap): def add_txt(ap):
ap2 = ap.add_argument_group("textfile options") ap2 = ap.add_argument_group("textfile options")
ap2.add_argument("--md-no-br", action="store_true", help="markdown: disable newline-is-newline; will only render a newline into the html given two trailing spaces or a double-newline (volflag=md_no_br)")
ap2.add_argument("--md-hist", metavar="TXT", type=u, default="s", help="where to store old version of markdown files; [\033[32ms\033[0m]=subfolder, [\033[32mv\033[0m]=volume-histpath, [\033[32mn\033[0m]=nope/disabled (volflag=md_hist)") ap2.add_argument("--md-hist", metavar="TXT", type=u, default="s", help="where to store old version of markdown files; [\033[32ms\033[0m]=subfolder, [\033[32mv\033[0m]=volume-histpath, [\033[32mn\033[0m]=nope/disabled (volflag=md_hist)")
ap2.add_argument("--txt-eol", metavar="TYPE", type=u, default="", help="enable EOL conversion when writing documents; supported: CRLF, LF (volflag=txt_eol)") ap2.add_argument("--txt-eol", metavar="TYPE", type=u, default="", help="enable EOL conversion when writing documents; supported: CRLF, LF (volflag=txt_eol)")
ap2.add_argument("-mcr", metavar="SEC", type=int, default=60, help="the textfile editor will check for serverside changes every \033[33mSEC\033[0m seconds") ap2.add_argument("-mcr", metavar="SEC", type=int, default=60, help="the textfile editor will check for serverside changes every \033[33mSEC\033[0m seconds")

View file

@ -2811,7 +2811,8 @@ class AuthSrv(object):
"have_mv": not self.args.no_mv, "have_mv": not self.args.no_mv,
"have_del": not self.args.no_del, "have_del": not self.args.no_del,
"have_unpost": int(self.args.unpost), "have_unpost": int(self.args.unpost),
"have_emp": self.args.emp, "have_emp": int(self.args.emp),
"md_no_br": int(vf.get("md_no_br") or 0),
"ext_th": vf.get("ext_th_d") or {}, "ext_th": vf.get("ext_th_d") or {},
"sb_md": "" if "no_sb_md" in vf else (vf.get("md_sbf") or "y"), "sb_md": "" if "no_sb_md" in vf else (vf.get("md_sbf") or "y"),
"sba_md": vf.get("md_sba") or "", "sba_md": vf.get("md_sba") or "",

View file

@ -44,6 +44,7 @@ def vf_bmap() -> dict[str, str]:
"gsel", "gsel",
"hardlink", "hardlink",
"magic", "magic",
"md_no_br",
"no_db_ip", "no_db_ip",
"no_sb_md", "no_sb_md",
"no_sb_lg", "no_sb_lg",
@ -324,6 +325,7 @@ flagcats = {
"og_ua": "if defined: only send OG html if useragent matches this regex", "og_ua": "if defined: only send OG html if useragent matches this regex",
}, },
"textfiles": { "textfiles": {
"md_no_br": "newline only on double-newline or two tailing spaces",
"md_hist": "where to put markdown backups; s=subfolder, v=volHist, n=nope", "md_hist": "where to put markdown backups; s=subfolder, v=volHist, n=nope",
"exp": "enable textfile expansion; see --help-exp", "exp": "enable textfile expansion; see --help-exp",
"exp_md": "placeholders to expand in markdown files; see --help", "exp_md": "placeholders to expand in markdown files; see --help",

View file

@ -4933,7 +4933,8 @@ class HttpCli(object):
"lastmod": int(ts_md * 1000), "lastmod": int(ts_md * 1000),
"lang": self.args.lang, "lang": self.args.lang,
"favico": self.args.favico, "favico": self.args.favico,
"have_emp": self.args.emp, "have_emp": int(self.args.emp),
"md_no_br": int(vn.flags.get("md_no_br") or 0),
"md_chk_rate": self.args.mcr, "md_chk_rate": self.args.mcr,
"md": boundary, "md": boundary,
"arg_base": arg_base, "arg_base": arg_base,

View file

@ -19292,7 +19292,7 @@ function show_md(md, name, div, url, depth) {
var marked_opts = { var marked_opts = {
headerPrefix: 'md-', headerPrefix: 'md-',
breaks: true, breaks: !md_no_br,
gfm: true gfm: true
}; };
var ext = md_plug.pre; var ext = md_plug.pre;

View file

@ -130,7 +130,8 @@ write markdown (most html is 🙆 too)
var SR = "{{ r }}", var SR = "{{ r }}",
last_modified = {{ lastmod }}, last_modified = {{ lastmod }},
have_emp = {{ "true" if have_emp else "false" }}, have_emp = {{ have_emp }},
md_no_br = {{ md_no_br }},
dfavico = "{{ favico }}"; dfavico = "{{ favico }}";
var md_opt = { var md_opt = {

View file

@ -201,7 +201,7 @@ function convert_markdown(md_text, dest_dom) {
var marked_opts = { var marked_opts = {
//headerPrefix: 'h-', //headerPrefix: 'h-',
breaks: true, breaks: !md_no_br,
gfm: true gfm: true
}; };

View file

@ -28,7 +28,8 @@
var SR = "{{ r }}", var SR = "{{ r }}",
last_modified = {{ lastmod }}, last_modified = {{ lastmod }},
have_emp = {{ "true" if have_emp else "false" }}, have_emp = {{ have_emp }},
md_no_br = {{ md_no_br }},
dfavico = "{{ favico }}"; dfavico = "{{ favico }}";
var md_opt = { var md_opt = {

View file

@ -143,7 +143,7 @@ class Cfg(Namespace):
def __init__(self, a=None, v=None, c=None, **ka0): def __init__(self, a=None, v=None, c=None, **ka0):
ka = {} ka = {}
ex = "allow_flac allow_wav chpw cookie_lax daw dav_auth dav_mac dav_rt e2d e2ds e2dsa e2t e2ts e2tsr e2v e2vu e2vp early_ban ed emp exp force_js getmod grid gsel hardlink hardlink_only ih ihead localtime magic nid nih no_acode no_athumb no_bauth no_clone no_cp no_dav no_db_ip no_del no_dirsz no_dupe no_fnugg no_lifetime no_logues no_mv no_pipe no_poll no_readme no_robots no_sb_md no_sb_lg no_scandir no_tail no_tarcmp no_thumb no_vthumb no_u2abrt no_zip nrand nsort nw og og_no_head og_s_title ohead q rand re_dirsz reflink rmagic rss smb srch_dbg srch_excl stats uqe usernames vague_403 vc ver wo_up_readme write_uplog xdev xlink xvol zipmaxu zs" ex = "allow_flac allow_wav chpw cookie_lax daw dav_auth dav_mac dav_rt e2d e2ds e2dsa e2t e2ts e2tsr e2v e2vu e2vp early_ban ed emp exp force_js getmod grid gsel hardlink hardlink_only ih ihead localtime magic md_no_br nid nih no_acode no_athumb no_bauth no_clone no_cp no_dav no_db_ip no_del no_dirsz no_dupe no_fnugg no_lifetime no_logues no_mv no_pipe no_poll no_readme no_robots no_sb_md no_sb_lg no_scandir no_tail no_tarcmp no_thumb no_vthumb no_u2abrt no_zip nrand nsort nw og og_no_head og_s_title ohead q rand re_dirsz reflink rmagic rss smb srch_dbg srch_excl stats uqe usernames vague_403 vc ver wo_up_readme write_uplog xdev xlink xvol zipmaxu zs"
ka.update(**{k: False for k in ex.split()}) ka.update(**{k: False for k in ex.split()})
ex = "dav_inf dedup dotpart dotsrch hook_v no_dhash no_fastboot no_fpool no_htp no_rescan no_sendfile no_ses no_snap no_up_list no_voldump re_dhash see_dots plain_ip" ex = "dav_inf dedup dotpart dotsrch hook_v no_dhash no_fastboot no_fpool no_htp no_rescan no_sendfile no_ses no_snap no_up_list no_voldump re_dhash see_dots plain_ip"