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

SCDoc: add various punctuation marks for non-code text and comments in code #6263

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from

Conversation

prko
Copy link
Contributor

@prko prko commented Apr 21, 2024

This PR allows you to insert various quotation marks, ellipses and brackets using predefined character combinations.

Screenshot 2024-04-22 at 03 09 55

Screenshot 2024-04-22 at 03 29 45

Purpose and motivation

When writing educational material using SCdoc, I needed to use

  • various quotation marks for non-code, text other than ' and ",
  • an apostrophe for non-code text other than ',
  • various brackets for non-code text other than () and []: brackets to indicate the year, brackets for additional explanation, and brackets to indicate the origin of terms (most Korean computer music terms are translations of European terms, and often an English expression is translated into a different expression when used for a different situation).

Inserting such punctuation from the character map is somewhat time-consuming and reduces productivity.
To solve these problems and improve productivity, I created this PR.

Types of changes

  • Documentation
  • New feature

To-do list

  • Code is tested
  • All tests are passing
  • Updated documentation
  • This PR is ready for review

various quotation marks and punctuation marks to improve readability
typo correction
typo correction
@prko
Copy link
Contributor Author

prko commented Apr 21, 2024

@JordanHendersonMusic
Copy link
Contributor

A part of #6260

Unnecessary part deleted
@prko
Copy link
Contributor Author

prko commented Apr 30, 2024

@JordanHendersonMusic
The bugs described in #6278 can be avoided with this PR.

The complete list of the same bug in built-in core schelp files:
#6278 (comment)

@prko prko changed the title SCDoc improvements: 2. added various punctuation marks (brackets, quotes, ellipses, etc) for non-code text SCDoc improvements: 2. added various punctuation marks (brackets, quotes, ellipses, Apostrophe etc) for non-code text May 2, 2024
@prko
Copy link
Contributor Author

prko commented May 10, 2024

In this PR, _ is used to enable various punctuation marks, but a word starting with _ is related to primitives by its colour. This can be a bit confusing for developers or other users who know these relationships, it may be better to use / instead of _.

@prko
Copy link
Contributor Author

prko commented May 17, 2024

Converted PDF from the corresponding reference in SCDoc included in this PR:
Non-code punctuation marks and symbols _ SuperCollider 3.14.0-dev Help.pdf

@@ -329,7 +368,7 @@ SCDocHTMLRenderer {
};
stream
<< "</h1>\n"
<< "<div id='summary'>" << this.escapeSpecialChars(doc.summary) << "</div>\n"
<< "\n<div id='summary'>" << SCDocHTMLRenderer.renderNonCodePunctuation(this.escapeSpecialChars(doc.summary)) << "</div>\n"
Copy link
Member

Choose a reason for hiding this comment

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

why not instead of SCDocHTMLRenderer.renderNonCodePunctuation(this.escapeSpecialChars(string))

this.renderNonCodePunctuation(this.escapeSpecialChars(string))?

But also I find it hard to unsderstand what kind of transfromations are applied to what kind of section. Why has \CODE no renderNonCodePunctuation?

It would be good if you could try and give intention revealing names so that all in all we improve the clarity and not make it even harder.

Copy link
Contributor Author

@prko prko May 19, 2024

Choose a reason for hiding this comment

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

why not instead of SCDocHTMLRenderer.renderNonCodePunctuation(this.escapeSpecialChars(string))

this.renderNonCodePunctuation(this.escapeSpecialChars(string))?

I followed your instructions and updated all the relevant parts. When I started creating the PRs, I used the format this.newMethodInMyPR. However, I didn't use this. when I was calling more than two methods. I cannot remember the reason exactly, but the form you recommended is better! Thanks!

But also I find it hard to unsderstand what kind of transfromations are applied to what kind of section. Why has \CODE no renderNonCodePunctuation?

I did not add renderNonCodePunctuation to \code, \codeblock etc. because I thought that special characters could be used in comments, but that they were not so useful. I have now added renderNonCodePunctuation to \code, \codeblock etc.

It would be good if you could try and give intention revealing names so that all in all we improve the clarity and not make it even harder.

I will do it! Thanks for pointing it out.

Copy link
Member

@telephon telephon May 19, 2024

Choose a reason for hiding this comment

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

Thanks! Yes, if you think about the intent of each of the string manipulations (also those that you haven't touched), maybe you can find a clear reasoning. Something like:

prepareStringForCode
prepareStringForNonCode

these could then include the escapeSpecialChars and renderNonCodePunctuation.

By the way "render" implies that something is done to convert to graphics. This is not really the case here, so the above would be better maybe.

But:

I am now a little wary about all the special syntax this introduces in the helfile. Already now it is really hard if you don't know it, and making it more complicated won't help much in people being able to read the source of help docs and learning from them how to write them.

Maybe the new LaTeX support might make a clearer and more powerful way of doing this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! Yes, if you think about the intent of each of the string manipulations (also those that you haven't touched), maybe you can find a clear reasoning. Something like:

prepareStringForCode
prepareStringForNonCode

these could then include the escapeSpecialChars and >renderNonCodePunctuation.

I changed the name of the method from .renderNonCodePunctuation to .prepareStringForNonCode (I need time to think about how to combine it with escapeSpecialChars.):

Instead of using .renderNonCodePunctuation, I think .prepareStringForNonCode seems appropriate. Um, and the current method, escapeSpecialChars, only replaces three characters, &, < and >, which prevent corruption when converting SCDoc contents to HTML... So you can add them to prepareStringForNonCode.

By the way "render" implies that something is done to convert to graphics. This is not really the case here, so the above would be better maybe.

In other related PRs I have used the method names pareHTML and parseMathML. In this PR I have used the term .renderNonCodePunctuation because the font size changes when some brackets are used:
https://github.com/prko/supercollider/blob/014a425e28343822cf43460be9800256a417fa63/SCClassLibrary/SCDoc/SCDocRenderer.sc#L57-L62

		.replace(/*"%E2%9D%AA"*/"/f(/", "<span style='font-size: 0.85em'>❪") // MEDIUM FLATTENED
		.replace(/*"%E2%9D%AB"*/"/f)/", "❫</span>")
		.replace(/*"%E2%9D%A8"*/"/m(/", "<span style='font-size: 0.85em'>❨") // MEDIUM
		.replace(/*"%E2%9D%A9"*/"/m)/", "❩</span>")
		.replace(/*"%E2%9D%B2"*/"/s(/", "<span style='font-size: 0.71em'>❲") // TORTOISE SHELL
		.replace(/*"%E2%9D%B3"*/"/s)/", "❳</span>")

However, I was not sure if the method name was appropriate. Thanks for pointing this out!


Maybe the new LaTeX support might make a clearer and more powerful way of doing this?

I am intending to include the following characters:


		.replace("&amp;hsp;",    "&#x3164;")
		.replace("&amp;#x20;",   "&#x20;"  ) // space.
		.replace("&amp;#32;",    "&#32;"   ) // space.
		.replace("&amp;hairsp;", "&hairsp;") // hair space. &#8202;
		.replace("&amp;#8239;",  "&#8239;" ) // narrow no-break space.
		.replace("&amp;ensp;",   "&ensp;"  ) // en space. &#8194;
		.replace("&amp;emsp;",   "&emsp;"  ) // em space. &#8195;
		.replace("&amp;emsp16;", "&#8198;" ) // 6-per-em space.
		.replace("&amp;emsp14;", "&emsp14;") // 4-per-em space. &#8197;
		.replace("&amp;emsp13;", "&emsp13;") // 3-per-em space. &#8196;
		.replace("&amp;thinsp;", "&thinsp;") // thin space. &#8201;
		.replace("&amp;nbsp;",   "&nbsp;"  ) // non breaking space. &#160;
		.replace("&amp;puncsp;", "&puncsp;") // punctuation space. &#8200;
		.replace("&amp;numsp;",  "&numsp;" ) // figure space. &#8199;
		.replace("&amp;#x3164;", "&#x3164;") // Hangul Filler.

The various spaces above and some of the characters included in the PR whether they are linked with the size of characters or not, can not be used via KaTes if I correctly understand KaTeX....

I am now a little wary about all the special syntax this introduces in the helfile. Already now it is really hard if you don't know it, and making it more complicated won't help much in people being able to read the source of help docs and learning from them how to write them.

Even though I made this PR, I am not sure which way is better:

  • Copy special characters from the character map
    (since SC-IDE does not have its own character map, the system's built-in character map should be used, but the workflow is not as different as using typesetting tools)
  • Place the symbols using the method described in this PR.

What I can say is,

  • In LaTeX and Mathematica, the special symbols are entered via code, not by selecting characters from the character map.
  • I switched from Finale to Dorico in 2018. I was a long-time Finale user. I find Dorico's workflow much more intuitive and faster. One reason for this is Dorico's popover, which allows users to place all musical symbols by typing in words, similar to what I did in this PR.

If someone wanted to write the following paragraph in SCD right now

Sie können jeden einzeiligen Ausdruck ausführen, indem Sie auf eine beliebige Stelle in der Zeile klicken und die „Enter“-Taste drücken. Bitte beachten Sie, dass die „Enter“-Taste nicht mit der „Return“-Taste identisch ist.

" and " should be copied from the character map or the text should be written using e.g. Microsoft Word.

However, if this PR is approved, " and " can easily be expressed in SCDoc.
So I think it would be a good idea to discuss making it easier to abbreviate each symbol. However, I cannot push this idea if none of the main developers agree. I also understand what you are thinking, as I was also very hesitant before making this PR.

updated according to the review
@prko prko changed the title SCDoc improvements: 2. added various punctuation marks (brackets, quotes, ellipses, Apostrophe etc) for non-code text SCDoc: add various punctuation marks for non-code text and comments in code May 19, 2024
change method name proposed in this PR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp: SCDoc scdoc syntax, parser, and renderer. for changes to schelp files, use "comp: help"
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants