Skip to content
This repository has been archived by the owner on Jun 7, 2023. It is now read-only.

Micro Parsons: Render blocks raw when all blocks are html in non-html problems #1397

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

amy21206
Copy link
Contributor

RunestoneInteractive/rs#20

Render blocks raw when micro Parsons find all blocks contain HTML, and when the language is not html.

Reason for asking all blocks to contain HTML:
a complete HTML can be used as a string in other languages, e.g. in Python, re.match('<b>', '<b>content</b>')

Two examples are shown below (included in test).

image

image

micro-Parsons dependency is updated in this PR, so npm install is needed.

@@ -80,6 +81,22 @@ export default class HParsons extends RunestoneBase {
this.originalBlocks = this.processSingleContent(code, '--blocks--').split('\n').slice(1,-1);
this.hiddenSuffix = this.processSingleContent(code, '--hiddensuffix--');
this.unittest = this.processSingleContent(code, '--unittest--');
// (for pretext) if all blocks can be parsed as html but language is not html,
// ask micro parsons to render raw
if (this.language != 'html') {
Copy link
Member

@bnmnetp bnmnetp May 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the logic of checking for not html. I think you should check for language == 'natural' or 'math'. Those are the cases where we want the html formatting to show through. Other languages should be verbatim as you have it I think. @rbeezer correct me if I'm wrong.

@rbeezer
Copy link

rbeezer commented May 16, 2023

Yes, an author's source should specify "natural" language, or a computer language. (There might be a default for authors, perhaps for historical reasons.)

But in any event, the generated HTML for the problem should have an explicit attribute to that effect which the code here can react to unambiguously.

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

Successfully merging this pull request may close these issues.

3 participants