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

follow-up #18013 - inline syntax highlighting #18166

Merged
merged 1 commit into from
Jun 4, 2021

Conversation

a-mr
Copy link
Contributor

@a-mr a-mr commented Jun 3, 2021

This should be the final PR for enabling inline highlighting in standalone rst files.


```nim
Copy link
Member

@timotheecour timotheecour Jun 3, 2021

Choose a reason for hiding this comment

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

so when can i use

```nim
some code...
```

(which brings us closer to markdown, which is good) ? can any instead of

.. code-block:: cmd
  some code...

be replaced or are there conditions?

Copy link
Contributor Author

@a-mr a-mr Jun 3, 2021

Choose a reason for hiding this comment

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

always, they are equivalent. You can write ```cmd and ```nim and any other language.

However note bug 22 from #17340. When it's resolved we can convert to using this Markdown style as a unified style in this repo just as you wanted.

There is 1 thing that I don't like about Markdown style: addition of those spaces at the beginning of lines. It would be good to visually distinguish code lines in documentation by additional indentation without adding them into final document.

I'd prefer to pass the code block between ``` through dedent. WDYT?

(That does not comply to Markdown spec but it seems as a reasonable default)

Copy link
Contributor Author

@a-mr a-mr Jun 3, 2021

Choose a reason for hiding this comment

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

Actually I found in the specification

https://spec.commonmark.org/0.29/#fenced-code-block

If the leading code fence is indented N spaces, then up to N spaces of indentation are removed from each line of the content (if present).

And this does actually work in Github:

  ```
  some code
  ```
some code

Copy link
Member

Choose a reason for hiding this comment

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

cool;

can you explain 22?
this seems to render fine with nim doc, doesn't it?

proc main*()=
  ##[
  foo1:
  ```nim
  echo 1
  ```
  * foo2:
    ```nim
    echo 2
    ```
  ]##

main()

Copy link
Contributor Author

@a-mr a-mr Jun 3, 2021

Choose a reason for hiding this comment

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

add e.g. two additional spaces as indentation before echo 1 or echo 2. And they will disappear.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

filed bug 23 in the same place :-)

@Araq Araq merged commit 7e21218 into nim-lang:devel Jun 4, 2021
PMunch pushed a commit to PMunch/Nim that referenced this pull request Mar 28, 2022
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

Successfully merging this pull request may close these issues.

3 participants