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

Add syntax highlighting to chapter docs #12

Open
neelabhg opened this issue Nov 13, 2015 · 1 comment
Open

Add syntax highlighting to chapter docs #12

neelabhg opened this issue Nov 13, 2015 · 1 comment

Comments

@neelabhg
Copy link
Member

The chapter exercise documentation (in the chapters/ directory) is written in markdown, and is shown in the "challenge doc" pane (the upper-right pane) in the sys playground.

sys supports GitHub Flavored Markdown (GFM), which supports syntax highlighting for source code.

The current challenge docs do not have syntax highlighting because the code blocks do not have any language identifier. For example, this file has the following fenced code block:

1. Spot the mistake(s) in the following code:
```
  for(len = 0; len <5 ; len++) {
      write(STDOUT_FNO,"I think", 6);
      write(STDOUT_FILENUM,"\n", 6); 
  }
```

which is rendered as

  1. Spot the mistake(s) in the following code:
  for(len = 0; len <5 ; len++) {
      write(STDOUT_FNO,"I think", 6);
      write(STDOUT_FILENUM,"\n", 6); 
  }

This can be syntax-highlighted by using the "c" language identifier:

> 1. Spot the mistake(s) in the following code:
```c
  for(len = 0; len <5 ; len++) {
      write(STDOUT_FNO,"I think", 6);
      write(STDOUT_FILENUM,"\n", 6); 
  }
```

which will render as

  1. Spot the mistake(s) in the following code:
  for(len = 0; len <5 ; len++) {
      write(STDOUT_FNO,"I think", 6);
      write(STDOUT_FILENUM,"\n", 6); 
  }

which is a much better appearance.

The task is to go through current chapters and modify them to use syntax highlighting, and write a document directing future documentation to be written this way.

@angrave
Copy link
Contributor

angrave commented Nov 13, 2015

Can you try a bit of perl pie
e.g. something like

perl -p -i -e 's/^`{3,4}[\s]$/```c/' chapters/
(may want to add the correct file extension to the *)

^ start of line
` 3 or 4 of them
optional whitespace
$ end of line

http://perldoc.perl.org/perlre.html#Regular-Expressions

On 11/12/15 11:26 PM, Neelabh Gupta wrote:

The chapter exercise documentation (in the |chapters/| directory) is
written in markdown, and is shown in the "challenge doc" pane (the
upper-right pane) in the sys playground.

sys supports GitHub Flavored Markdown (GFM), which supports syntax
highlighting
https://urldefense.proofpoint.com/v2/url?u=https-3A__help.github.com_articles_github-2Dflavored-2Dmarkdown_-23syntax-2Dhighlighting&d=BQMCaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=DvT4PEagC1_uJoK7XYcVznCf9vBnV8AqDdM20MaTLvM&m=NsUujashXs4IEYXWydO5nrmaMBs_d_rMiPjsfMXH0f8&s=PEMsQb7GhjiNp2V0ipC60_rZAmvxkzJUcMFhMmubmT0&e=
for source code.

The current challenge docs do not have syntax highlighting because the
code blocks do not have any language identifier. For example, this
file
https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_cs-2Deducation_sysassets_blob_gh-2Dpages_chapters_chapter01_play-2D2-2D1.md&d=BQMCaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=DvT4PEagC1_uJoK7XYcVznCf9vBnV8AqDdM20MaTLvM&m=NsUujashXs4IEYXWydO5nrmaMBs_d_rMiPjsfMXH0f8&s=ci38gBKc5uSMMENwXkMaGiZMC_ShiMhZSAr3pYvt9b4&e=
has the following fenced code block:

|1. Spot the mistake(s) in the following code: for(len = 0; len <5 ; len++) { write(STDOUT_FNO,"I think", 6); write(STDOUT_FILENUM,"\n", 6); } |

which is rendered as

 1. Spot the mistake(s) in the following code:

|for(len = 0; len <5 ; len++) { write(STDOUT_FNO,"I think", 6);
write(STDOUT_FILENUM,"\n", 6); } |

This can be syntax-highlighted by using the "c" language identifier:

|> 1. Spot the mistake(s) in the following code: c for(len = 0; len <5 ; len++) { write(STDOUT_FNO,"I think", 6); write(STDOUT_FILENUM,"\n", 6); } |

which will render as

 1. Spot the mistake(s) in the following code:

   for(len =0; len <5  ; len++) {
       write(STDOUT_FNO,"I think",6);
       write(STDOUT_FILENUM,"\n",6);
   }

a much better appearance.

The task is to go through current chapters and modify them to use
syntax highlighting, and write a document directing future
documentation to be written this way.


Reply to this email directly or view it on GitHub
https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_cs-2Deducation_sysassets_issues_12&d=BQMCaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=DvT4PEagC1_uJoK7XYcVznCf9vBnV8AqDdM20MaTLvM&m=NsUujashXs4IEYXWydO5nrmaMBs_d_rMiPjsfMXH0f8&s=GjSPB73Adpc3WbIfZlisRAPOyBaWthq9gh9haxc7wY4&e=.

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