Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature request] convert string, and store the result in a string variant #15

Open
retsyo opened this issue Dec 23, 2019 · 2 comments
Open

Comments

@retsyo
Copy link

retsyo commented Dec 23, 2019

In my case, I convert a markdown file to HTML which then is rendered with QT. The main code is

webView = QWebEngineView()
webView.setHtml(pageSource)

as you may have noticed, the contain pageSource is used here. If an HTML file is used, an extra step has to be performed

pageSource = open('page.html').read()

So what I suggest is

pageSource = codebraid.convert('web.cbmd', from='markdown', to='markdown',  ignorePandoc=True)

and in this case, I think pandoc is not necessary, so I set ignorePandoc=True

Thanks

@gpoore
Copy link
Owner

gpoore commented Dec 27, 2019

Codebraid is currently written as a command-line application. At the moment, I would recommend using it via subprocess.run(). If you want to avoid creating/reading temp files, you could use subprocess.PIPE to read the output from stdout.

I plan to make Codebraid usable as a library as well at some point, which would be more ideal for your case. It will probably be a while before library usage is possible, since several additional features need to be added first, and those may result in significant refactoring. If you want to use it as a library right now, take a look at cmdline.py. Just be aware that there are currently no stability guarantees for anything besides command-line usage.

Pandoc will always be necessary, because Pandoc is being used to parse the Markdown in addition to any format conversions.

@retsyo
Copy link
Author

retsyo commented Dec 28, 2019

Why I made this feature request

I try to make quiz sheet for classroom. In the sheet, there is only the choice question. During the preparation step, the choice items of every question are set randomly, and the right choice item(s) are marked( of cause I can not show the answer to the student); as a result, I can use program to score the returned sheet.

In this case, I think it will be safer if I prepare the quiz sheet as string in memory other than store it as a file on harddisk

So I am look forward to something like

pageSource = codebraid.convert('web.cbmd', from='markdown', to='markdown')

yet another question

is there any template in codebraid?
for example, for this code which should be displayed in the resulted markdown file

please choose your ID
A. 1
B. 2
C. 3
D. {{ID}}

if ID = 123 then the item D is 123

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants