Skip to content

Commit

Permalink
push
Browse files Browse the repository at this point in the history
  • Loading branch information
István Bozsó committed May 20, 2019
1 parent 6b83e97 commit b6db3f1
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .textadept/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ textadept.run.compile_commands["cpp"] = "ninja"
textadept.run.compile_commands["ansi_c"] = "ninja"
textadept.run.compile_commands["fortran"] = "ninja"

local cmd = "/home/istvan/progs/utils/menu.sh markdown %p"
local cmd = "python /home/istvan/progs/utils/utils.py markdown --infile %p"

-- textadept.run.compile_commands["markdown"] = cmd
textadept.run.run_commands["markdown"] = cmd
Expand Down
55 changes: 54 additions & 1 deletion utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,60 @@ def main():
pull_all()

elif args.mode == "markdown":
cmd = 'gpp -C --nostdinc %s -o %s +c "%" "\n"' % (args.infile, md_temp)
# User-defined mode. The nine following command-line arguments are
# taken to be respectively the macro start sequence, the macro end
# sequence for a call without arguments, the argument start sequence,
# the argument separator, the argument end sequence, the list of
# characters to stack for argument balancing, the list of characters
# to unstack, the string to be used for referring to an argument by
# number, and finally the quote character (if there is none an
# empty string should be provided).

# macro start, macro end, arg start, arg sep, arg end,
# char list to stack, char list to unstack, arg ref by num, quote char

# opts = '-U "\\\\" "" "{" "," "}" "{" "}" "#" "@"'
udef = {
"macro_start": "@",
"macro_end": r"",
"arg_start": "(",
"arg_end": ")",
"arg_sep": ",",
"stack": "(",
"unstack": ")",
"bynum": "#",
"quote": ""
}

mdef = {
"macro_start": r"\n#\w",
"macro_end": r"\n",
"arg_start": " ",
"arg_end": r"\n",
"arg_sep": " ",
"stack": "",
"unstack": "",
}

opts = (
'-U "{macro_start}" "{macro_end}" "{arg_start}" "{arg_sep}" '
'"{arg_end}" "{stack}" "{unstack}" "{bynum}" "{quote}" '
).format(**udef)


if 1:
opts += (
'-M "{macro_start}" "{macro_end}" "{arg_start}" "{arg_sep}" '
'"{arg_end}" "{stack}" "{unstack}"'
).format(**mdef)


cmd = 'gpp %s -n --nostdinc +c "/*" "*/" +c "%%" "\\n" %s -o %s' \
% (opts, args.infile, md_temp)


# print(cmd)

check_output(split(cmd))

else:
Expand Down

0 comments on commit b6db3f1

Please sign in to comment.