gpoore / codebraid

Live code in Pandoc Markdown
BSD 3-Clause "New" or "Revised" License
367 stars 13 forks source link

cannot loop through arrays in bash #28

Closed aguang closed 4 years ago

aguang commented 4 years ago

When I try to run the below code as a block in codebraid with options .bash .cb.run I get an error that appears to be related to formatting. However I cannot figure out what the issue is.

array=( one two three )
for i in "${array[@]}"
do
    echo ${i}
done

Error:

codebraid pandoc --from markdown --to markdown test_for.md
Traceback (most recent call last):
  File "/Users/aguang/miniconda3/bin/codebraid", line 10, in <module>
    sys.exit(main())
  File "/Users/aguang/miniconda3/lib/python3.6/site-packages/codebraid/cmdline.py", line 62, in main
    args.func(args)
  File "/Users/aguang/miniconda3/lib/python3.6/site-packages/codebraid/cmdline.py", line 85, in pandoc
    converter.code_braid()
  File "/Users/aguang/miniconda3/lib/python3.6/site-packages/codebraid/converters/base.py", line 1161, in code_braid
    self._extract_code_chunks()
  File "/Users/aguang/miniconda3/lib/python3.6/site-packages/codebraid/converters/pandoc.py", line 1146, in _extract_code_chunks
    self._load_and_process_initial_ast(source_string=source_string, single_source_name=source_name)
  File "/Users/aguang/miniconda3/lib/python3.6/site-packages/codebraid/converters/pandoc.py", line 1070, in _load_and_process_initial_ast
    source_name, line, line_number = next(source_name_line_and_number_iter)
StopIteration
gpoore commented 4 years ago

It looks like you have indentation using a tab, in which case this is a duplicate of #18. Basically, Pandoc converts tabs to spaces by default, and this breaks Codebraid's error syncing system.

I'm just wrapping up grading at the end of my semester, so I should be able to fix this and some of the other simpler bugs and release a new version over the next few days. In the meantime, indenting with spaces should work.

gpoore commented 4 years ago

This is fixed now in the dev version on GitHub (e36893c), and a new version will be on PyPI soon.