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

Code block not transformed correctly release 1.0.4 #1692

Closed
chenfj068 opened this issue Dec 1, 2018 · 24 comments
Closed

Code block not transformed correctly release 1.0.4 #1692

chenfj068 opened this issue Dec 1, 2018 · 24 comments

Comments

@chenfj068
Copy link

markdown code block not correct transformed,
eg .

a
b
c

the transformed content is

a b c

It seems that the newline characters are escaped

@froschdesign
Copy link

froschdesign commented Dec 1, 2018

@chenfj068
I can not reproduce the problem. Can you give a full example for your markdown code?
Btw. MkDocs uses Python-Markdown as parser. You should try parsing your markdown code directly with this parser.

@waylan
Copy link
Member

waylan commented Dec 1, 2018

Looking at the source of your comment, it appears that you have not included a blank line both before and after your code blocks. That could be the cause. However, without a proper example, it's hard to say. Please provide an example as source Markdown, not rendered HTML. In other words, copy a sample document in and nest the entire document in a code block.

@chenfj068
Copy link
Author

chenfj068 commented Dec 2, 2018

dataset.getColumnMetaData() 获取返回结果的元数据信息。使用datset的hasNext()和next()方法可迭代的获取数据。

```java
String datasource = "PRESTO";
String database = "basedb";
String table = "CMA15D12H";
String sql = "select * from CMA15D12H limit 200";
DataSet dataSet = client.executeQuery(datasource, database, table, sql);
ColumnMetaData metaData = dataSet.getColumnMetaData();
for (ColumnInfo column : metaData.getColumns()) {
  System.out.println(
      String.format("columnName:%s,dataType:%s", column.getName(), column.getType()));
}
int count = 0;
while (dataSet.hasNext()) {
  Row row = dataSet.next();
  count++;
  System.out.println(Arrays.asList(row.getRowValues()));
}
System.out.println(count);
```

some code piece like this, I rendered the .md file with python-markdown,output html was not correct.
It seems some problems with my md file format .
But the github pages shows correctly

@waylan
Copy link
Member

waylan commented Dec 2, 2018

I edited your comment to include the entire Markdown document in a code block. Did I get that correct?

It is still not clear to me what your problem is. In any event, if you are having a problem with Markdown rendering then that is an issue for Python-Markdown that you should report upstream. However, note that Python-Markdown is a Markdown parser, not a Commonmark parser (which is what GitHub uses). There are known differences between them.

@facelessuser
Copy link
Contributor

Are you including Python Markdown's fenced_code extension or a third party extension like pymdowx.superfences? If not, maybe that is your problem?

@waylan
Copy link
Member

waylan commented Dec 2, 2018

@facelessuser MkDocs includes fenced_code by default. So, unless there is another extension which is causing a conflict, I doubt that's the problem.

@facelessuser
Copy link
Contributor

@facelessuser MkDocs includes fenced_code by default.

Oh, I did not know that, I thought it was just toc. Glad that the fenced code extension I use safely overrides fenced_code when following it.

Well, I'm out of ideas without a clear reproducible example.

@chenfj068
Copy link
Author

Thanks @facelessuser @waylan
I render the .md file with python-markdown directly, fenced_code was not included,
I will check is there some extension conflict

@waylan
Copy link
Member

waylan commented Dec 2, 2018

I render the .md file with python-markdown directly, fenced_code was not included,

If you are directly calling Python-Markdown, then you need to explicitly include the extension. If you are using MkDocs, the extension is included for you.

@facelessuser, the docs for the markdown_extensions config setting state:

This setting lets you enable a list of extensions beyond the ones that MkDocs uses by default (meta, toc, tables, and fenced_code).

Although, technically, the meta extension is not used, but a variation of it. The details for all of the default extensions are documented in Writing your docs.

@facelessuser
Copy link
Contributor

@facelessuser, the docs for the markdown_extensions config setting state:

Sure, I didn't doubt it was documented, only that I didn't realize it. Like I said, I'm just glad my extension overrides it safely 🙂 .

@chenfj068
Copy link
Author

Thanks all
Some problem with the theme mkdocs-rtd-dropdown, I change it to readthedocs, and every thing is ok

@marcvs
Copy link

marcvs commented Feb 3, 2020

Sorry guys, I seem to be hit by this bug.

Bug occurs for themes
name: 'readthedocs'
name: 'rtd-dropdown'
But not for these:
name: 'rtd-mklab'
name: mkdocs

@waylan
Copy link
Member

waylan commented Feb 3, 2020

@marcvs what is the generated HTML for the code block. You may need to use your browser's "view source" or "inspect" tool to obtain the HTML. And please, do not paste your entire page, only the relevant section for the code block.

@marcvs
Copy link

marcvs commented Feb 3, 2020

This is the output in html:

<pre><code>     {
         &quot;local&quot;: [
             {
                 &quot;user&quot;: {
                     &quot;domain&quot;: { &quot;id&quot;: &quot;default&quot; },
                     &quot;name&quot;: &quot;{0}_egiID&quot;
                 },
                 &quot;group&quot;: {&quot;id&quot;: &quot;222333xxx&quot;}
             }
         ],
         &quot;remote&quot;: [
             {&quot;type&quot;: &quot;HTTP_OIDC_SUB&quot;},
             {
                 &quot;type&quot;: &quot;HTTP_OIDC_ISS&quot;,
                 &quot;any_one_of&quot;: [&quot;https://aai-demo.egi.eu/oidc/&quot;]
             },
             {
                 &quot;type&quot;: &quot;OIDC-eduperson_entitlement&quot;,
                 &quot;regex&quot;: true,
                 &quot;any_one_of&quot;: 
[&quot;^urn:mace:egi.eu:group:opencoast.eosc-hub.eu:role=vm_operator#.+$&quot;]
             }
         ]
     },
</code></pre>

@waylan
Copy link
Member

waylan commented Feb 3, 2020

That is a valid code block. If it is not displaying correctly, then that would be an issue with the theme's CSS. Is this a problem for all code blocks or only this specific one?

@marcvs
Copy link

marcvs commented Feb 3, 2020

It's a problem for all code blocks that I have. I'm using four in the project. Most with triple backtick, one with four spaces. Both result in being surrounded with

<pre><code> 
</code></pre>

@waylan
Copy link
Member

waylan commented Feb 3, 2020

Can you provide an example of the Markdown for a code block?

@marcvs
Copy link

marcvs commented Feb 3, 2020

```
This be code block
```

@marcvs
Copy link

marcvs commented Feb 3, 2020

I.e. literally, the text entered in github

@marcvs
Copy link

marcvs commented Feb 3, 2020

Screenshot of source here

@marcvs
Copy link

marcvs commented Feb 3, 2020

My generated html file includes several css files:

  <link rel="stylesheet" href="../css/theme.css" type="text/css" />
  <link rel="stylesheet" href="../css/theme_extra.css" type="text/css" />

Only if I comment out the first, changes in the latter become visible. Also the code is then fromatted correctly. Unfortunately most formatting seems to be done in that first file, which seems to be some kind of compiled/optimised css code. I uncompiled it and compared it with the working css. (I have no clue about css).
This patch fixes my problem:

--- theme-formatted-orig.css	2020-02-03 23:29:40.830503717 +0100
+++ theme-formatted-patched-to-work.css	2020-02-03 23:28:48.142198289 +0100
@@ -56,7 +56,7 @@
     font-style:italic;
     font-weight:bold
 }
-pre,code,.rst-content tt,.rst-content code,kbd,samp{
+pre,code,.rst-content tt,kbd,samp{
     font-family:monospace,serif;
     _font-family:"courier new",monospace;
     font-size:1em
@@ -3585,7 +3585,7 @@
     margin:24px 0;
     padding:0
 }
-code,.rst-content tt,.rst-content code{
+code,.rst-content tt{
     white-space:nowrap;
     max-width:100%;
     background:#fff;

@waylan
Copy link
Member

waylan commented Feb 3, 2020

I can't replicate your behavior. Regardless, note that the readthedocs theme is a clone of the Sphinx theme of the same name (which is the default theme used by the Read the Docs service). We simply use their CSS file (../css/theme.css) as is. Additionally, the upstream theme is built on a CSS framework, which is where most of the CSS comes from. Therefore, that file should never be edited except to copy new updates to the upstream theme (which we did in #1594 which will be available in the next release).

Any local modifications to the upstream theme to make it fit better with MkDocs are done in the ../css/theme_extra.css file. If you are not seeing those changes being applied, then perhaps there is a cascade or precedence issue. However, as I am not seeing any problem myself, I can't be of much help in determining what the issue is. That said, a PR is welcome if someone else can provide a solution.

Finally, note that the rtd-dropdown is a third party theme which is not maintained by the MkDocs project. You should contact the developers of that theme directly to address any issues with it.

@marcvs
Copy link

marcvs commented Feb 4, 2020

Thanks for the background info. I can patch that file locally as a workaround.

Finally, note that the rtd-dropdown is a third party theme which is not maintained by the MkDocs
project. You should contact the developers of that theme directly to address any issues with it.

Sure. But for the record: the same problem (no linebreaks found, "code" or "pre code" statement in theme_extra.css ignored) occurs for the shipped readthedocs theme.

@djbajic
Copy link

djbajic commented Jul 30, 2020

I'm running into this same problem, you can see a reproducible example by just cloning https://github.com/segrelab/comets-manual

I am not sure by reading the above whether this is the right place to ask, or I should ask the readthedocs folks?

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

6 participants