You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Alright, I was working on trying to get the following text to generate using SnakeMD:
There are 100 points on the exam. Please write your answers on the test sheets, and of course don’t forget to write and sign your name on the top sheet. Consider the space allotted as an indication of the expected length of the answer. Summaries of relevant Javadoc APIs are included in the handout. Please do not write on the handout , and return it with your exam. If you need to look up the Javadoc API for anything else or for more detail, your instructor will have a browser open on a computer in the classroom for you to use.
With the following code:
doc.add_block(
snakemd.Paragraph([
snakemd.Inline(
'There are 100 points on the exam. Please write your answers on the test sheets, and of course don’t forget to write and sign your name on the top sheet. Consider the space allotted as an indication of the expected length of the answer. Summaries of relevant Javadoc APIs are included in the handout. Please '
).italicize(),
snakemd.Inline(
'do not write on the handout '
).italicize().bold(),
snakemd.Inline(
', and '
).italicize(),
snakemd.Inline(
'return it '
).italicize().bold(),
snakemd.Inline(
'with your exam. If you need to look up the Javadoc API for anything else or for more detail, your instructor will have a browser open on a computer in the classroom for you to use.'
).italicize()
])
)
In the original design, I figured we would defer as much of the structure as possible to the user. This runs perfectly in line with the way folks already format their strings using concatenation. In other words, users would be expected to get their spacing right, just as you would with something like: "Hello, " + input("What is your name?").
The problem is that when styles are applied, they are applied to the individual inline units and there are some nastier bugs that can unexpectedly occur. For example, the code above produces the following nightmare:
_There are 100 points on the exam. Please write your answers on the test sheets, and of course don’t forget to write and sign your name on the top sheet. Consider the space allotted as an indication of the expected length of the answer. Summaries of relevant Javadoc APIs are included in the handout. Please **do not write on the handout **, and __**return it **_with your exam. If you need to look up the Javadoc API for anything else or for more detail, your instructor will have a browser open on a computer in the classroom for you to use.
To me, the whitespace should not affect the output but it seemingly does. Therefore, the correct code would be:
doc.add_block(
snakemd.Paragraph([
snakemd.Inline(
'There are 100 points on the exam. Please write your answers on the test sheets, and of course don’t forget to write and sign your name on the top sheet. Consider the space allotted as an indication of the expected length of the answer. Summaries of relevant Javadoc APIs are included in the handout. Please '
).italicize(),
snakemd.Inline(
'do not write on the handout'
).italicize().bold(),
snakemd.Inline(
' , and '
).italicize(),
snakemd.Inline(
'return it'
).italicize().bold(),
snakemd.Inline(
' with your exam. If you need to look up the Javadoc API for anything else or for more detail, your instructor will have a browser open on a computer in the classroom for you to use.'
).italicize()
])
)
In other words, anywhere we are applying both italics and bold would need to be free of trailing and leading spaces. I believe the reason this ends up being an issue is because adjacent Inline elements have italics which cause problems when running into each other.
Ultimately, I hate this because it's not something I want the users to have to worry about. They shouldn't have to really even know markdown to use the library, but they'll be stuck solving markdown bugs as a result.
Now, the solution would be applying italics to the entire Paragraph and bold to the key elements. Or in a broader sense, SnakeMD should maybe have the capability to aggregate repeated styles. Something to think about for sure!
The text was updated successfully, but these errors were encountered:
A dream of mine would be to borrow the f-string syntax somehow, so users basically would never have to touch the Inline object. For example, something like this would be wonderful:
Alright, I was working on trying to get the following text to generate using SnakeMD:
With the following code:
In the original design, I figured we would defer as much of the structure as possible to the user. This runs perfectly in line with the way folks already format their strings using concatenation. In other words, users would be expected to get their spacing right, just as you would with something like:
"Hello, " + input("What is your name?")
.The problem is that when styles are applied, they are applied to the individual inline units and there are some nastier bugs that can unexpectedly occur. For example, the code above produces the following nightmare:
To me, the whitespace should not affect the output but it seemingly does. Therefore, the correct code would be:
In other words, anywhere we are applying both italics and bold would need to be free of trailing and leading spaces. I believe the reason this ends up being an issue is because adjacent Inline elements have italics which cause problems when running into each other.
Ultimately, I hate this because it's not something I want the users to have to worry about. They shouldn't have to really even know markdown to use the library, but they'll be stuck solving markdown bugs as a result.
Now, the solution would be applying italics to the entire Paragraph and bold to the key elements. Or in a broader sense, SnakeMD should maybe have the capability to aggregate repeated styles. Something to think about for sure!
The text was updated successfully, but these errors were encountered: