Skip to content

Commit 912f9f8

Browse files
committed
Error out on detecting invalid header arg with missing colon
1 parent 5307940 commit 912f9f8

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

src/ntangle.nim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ proc getHeaderArgs(s: string): LangAndArgs =
366366
dbg "spaceSepParts: {spaceSepParts}"
367367
if spaceSepParts.len >= 3 and
368368
spaceSepParts[0].toLowerAscii() == "#+property:":
369+
doAssert spaceSepParts[2][0] == ':'
369370
headerArgsRaw = spaceSepParts[2 .. spaceSepParts.high]
370371
let
371372
kwdParts = spaceSepParts[1].split(":")
@@ -375,6 +376,7 @@ proc getHeaderArgs(s: string): LangAndArgs =
375376
# ":header-args:", ":header-args+:", ":header-args:nim:"
376377
elif spaceSepParts.len >= 3 and
377378
spaceSepParts[0].toLowerAscii().startsWith(":header-args"):
379+
doAssert spaceSepParts[1][0] == ':'
378380
headerArgsRaw = spaceSepParts[1 .. spaceSepParts.high]
379381
let
380382
kwdParts = spaceSepParts[0].split(":")
@@ -384,6 +386,7 @@ proc getHeaderArgs(s: string): LangAndArgs =
384386
elif spaceSepParts.len >= 2 and
385387
spaceSepParts[0].toLowerAscii() == "#+begin_src":
386388
if spaceSepParts.len >= 3:
389+
doAssert spaceSepParts[2][0] == ':'
387390
headerArgsRaw = spaceSepParts[2 .. spaceSepParts.high]
388391
lang = spaceSepParts[1].strip()
389392
haType = haBeginSrc
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Below block should not be tangled.
2+
#+begin_src nim tangle yes
3+
echo "this source block has an invalid tangle arg, no colon"
4+
#+end_src

tests/test.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env bash
2-
# Time-stamp: <2018-10-05 13:51:42 kmodi>
2+
# Time-stamp: <2018-10-07 00:27:00 kmodi>
33

44
set -euo pipefail # http://redsymbol.net/articles/unofficial-bash-strict-mode
55
IFS=$'\n\t'
@@ -17,6 +17,7 @@ run_test () {
1717
"${bin}" tests/nested_src/
1818

1919
"${bin}" tests/missing_arg_value/missing_arg_value.org || true
20+
"${bin}" tests/invalid_arg_no_colon/ || true
2021

2122
rm -rf ./tests/foo/bar/
2223
"${bin}" tests/mkdirp_no/mkdirp_no.org || true

tests/wyag/write-yourself-a-git.org

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1695,7 +1695,7 @@ that they come in two flavors: lightweight tags and tags objects.
16951695
We don't even need to implement tag objects, we can reuse =GitCommit=
16961696
and just change the =fmt= field:
16971697

1698-
#+BEGIN_SRC python tangle libwyag.py
1698+
#+BEGIN_SRC python :tangle libwyag.py
16991699
class GitTag(GitCommit):
17001700
fmt = b'tag'
17011701
#+END_SRC

0 commit comments

Comments
 (0)