diff --git a/copyparty/__main__.py b/copyparty/__main__.py index 3cb97949..120d3481 100644 --- a/copyparty/__main__.py +++ b/copyparty/__main__.py @@ -1634,6 +1634,7 @@ def add_db_metadata(ap): def add_txt(ap): 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("--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") diff --git a/copyparty/authsrv.py b/copyparty/authsrv.py index de8e764c..1b922c22 100644 --- a/copyparty/authsrv.py +++ b/copyparty/authsrv.py @@ -2811,7 +2811,8 @@ class AuthSrv(object): "have_mv": not self.args.no_mv, "have_del": not self.args.no_del, "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 {}, "sb_md": "" if "no_sb_md" in vf else (vf.get("md_sbf") or "y"), "sba_md": vf.get("md_sba") or "", diff --git a/copyparty/cfg.py b/copyparty/cfg.py index 4fa73e72..51c47853 100644 --- a/copyparty/cfg.py +++ b/copyparty/cfg.py @@ -44,6 +44,7 @@ def vf_bmap() -> dict[str, str]: "gsel", "hardlink", "magic", + "md_no_br", "no_db_ip", "no_sb_md", "no_sb_lg", @@ -324,6 +325,7 @@ flagcats = { "og_ua": "if defined: only send OG html if useragent matches this regex", }, "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", "exp": "enable textfile expansion; see --help-exp", "exp_md": "placeholders to expand in markdown files; see --help", diff --git a/copyparty/httpcli.py b/copyparty/httpcli.py index 885a5fb9..695c5213 100644 --- a/copyparty/httpcli.py +++ b/copyparty/httpcli.py @@ -4933,7 +4933,8 @@ class HttpCli(object): "lastmod": int(ts_md * 1000), "lang": self.args.lang, "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": boundary, "arg_base": arg_base, diff --git a/copyparty/web/browser.js b/copyparty/web/browser.js index e86b3c54..fb6fea90 100644 --- a/copyparty/web/browser.js +++ b/copyparty/web/browser.js @@ -19292,7 +19292,7 @@ function show_md(md, name, div, url, depth) { var marked_opts = { headerPrefix: 'md-', - breaks: true, + breaks: !md_no_br, gfm: true }; var ext = md_plug.pre; diff --git a/copyparty/web/md.html b/copyparty/web/md.html index c3e2dfce..1dfed659 100644 --- a/copyparty/web/md.html +++ b/copyparty/web/md.html @@ -130,7 +130,8 @@ write markdown (most html is 🙆 too) var SR = "{{ r }}", last_modified = {{ lastmod }}, - have_emp = {{ "true" if have_emp else "false" }}, + have_emp = {{ have_emp }}, + md_no_br = {{ md_no_br }}, dfavico = "{{ favico }}"; var md_opt = { diff --git a/copyparty/web/md.js b/copyparty/web/md.js index 9ab5a2fc..d6064c9e 100644 --- a/copyparty/web/md.js +++ b/copyparty/web/md.js @@ -201,7 +201,7 @@ function convert_markdown(md_text, dest_dom) { var marked_opts = { //headerPrefix: 'h-', - breaks: true, + breaks: !md_no_br, gfm: true }; diff --git a/copyparty/web/mde.html b/copyparty/web/mde.html index adef6793..f6d0940f 100644 --- a/copyparty/web/mde.html +++ b/copyparty/web/mde.html @@ -28,7 +28,8 @@ var SR = "{{ r }}", last_modified = {{ lastmod }}, - have_emp = {{ "true" if have_emp else "false" }}, + have_emp = {{ have_emp }}, + md_no_br = {{ md_no_br }}, dfavico = "{{ favico }}"; var md_opt = { diff --git a/tests/util.py b/tests/util.py index 2318bab7..9b1a0e27 100644 --- a/tests/util.py +++ b/tests/util.py @@ -143,7 +143,7 @@ class Cfg(Namespace): def __init__(self, a=None, v=None, c=None, **ka0): 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()}) 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"