【问题标题】:Jekyll markdown not displaying like the original and general style problemsJekyll markdown 不像原始和一般样式问题那样显示
【发布时间】:2017-08-20 13:01:16
【问题描述】:

我们有一篇用 Markdown 编写的博客文章,我们希望在托管在 GithubPages 上的 Jekyll 页面上实现该文章。

这里是帖子的降价代码摘录:

```python
import keras
```

**TensorFlow:**

```python
import tensorflow as tf
```

## Building the Model

**Keras:**

We can easily create linear to complex models through the [`sequential`](https://keras.io/models/sequential/) API, which stacks up layers in a linear fashion. For linear regression, we can write this as follow:

```python
from keras.models import Sequential
from keras.layers.core import Dense

model = Sequential()
model.add(Dense(units=1, activation="linear", input_dim=1))
```

* Keras includes many commonly used layers:
    - Regular `dense` layers for feed-forward neural networks
    - `Dropout`, `normalization` and `noise` layers to prevent overfitting and improve learning
    - Common `convolutional` and `pooling layers` (max and average) for CNNs
    - `Flatten` layers to add fully connected layers after convolutional nets
    - `Embedding` layers for Word2Vec problems
    - `Recurrent` layers (simpleRNN, GRU and LSTM) for RNNs
    - `Merge` layers to combine more than one neural net
    - Many more… you can also [write your own Keras layers](https://keras.io/layers/writing-your-own-keras-layers/)
* Many common activation functions are available like `relu`, `tanh` and `sigmoid` depending on the problem that you like to solve (read [“Yes you should understand backprop” by Andrej Karpathy](https://medium.com/@karpathy/yes-you-should-understand-backprop-e2f06eab496b) if you want to understand the effect of backpropagation on some activation functions)
* The activation function can also be passed through an `Activation` layer instead of the `activation` argument

Alternatively if you prefer one-liners, we could have also done something like this:

```python
model = Sequential([Dense(units=1, activation="linear", input_dim=1)])
```

Or we could have used [Keras’s functional API](https://keras.io/getting-started/functional-api-guide/):

```python
from keras.models import Model
from keras.layers import Dense, Input

它应该是这样的(在 README.md 中显示在 Github 上):

这是我们最终的 post.md 在托管的 Jekyll 页面上的外观:

这是 _config.yml:

title: BML
email:xxx@gmail.com
description: > # this means to ignore newlines until "baseurl:"
  Write an awesome description for your new site here. You can edit this
  line in _config.yml. It will appear in your document head meta (for
  Google search results) and in your feed.xml site description.
baseurl: "" # the subpath of your site, e.g. /blog
url: "" # the base hostname & protocol for your site, e.g. http://example.com
twitter_username: xyz
github_username:  xyz
future: true
# Build settings
markdown: kramdown
highlighter: rouge
theme: minima
gems:
  - jekyll-feed
exclude:
  - Gemfile
  - Gemfile.lock

我们花了几个小时寻找如何完成这项工作,到目前为止我们的结果和实现是:

  • 似乎没有一种合理的方法可以将用 markdown 编写的帖子实现到 Jekyll 中
  • 结果非常令人不快(列表混乱、代码块不是很好、奇怪的间距和垂直距离)
  • 我必须实现一些 syntax.css 来设置代码块样式
  • Jekyll 强迫我们使用 kramdown
  • markdown 到 kramdown 的转换并不容易(kramdown 在某些地方似乎有不同的语法)

我也不太明白,为什么?列表在没有任何样式的情况下呈现,尽管它们在 DOM 中正确注册为 ul li 元素。用于<ul> 元素的list-style: none; 来自呈现到网站头部的一些内联<style type="text/css">。真的不知道它来自哪里,也许是主题? 如果没有这个样式标签,至少列表看起来更好......

我尝试过使用 kramdown="1" 属性,玩弄缩进和许多其他“技巧”和结构。

  1. 有没有什么简单的方法可以像在 Github 上一样呈现真正的 Markdown?
  2. 如何知道这个奇怪的样式标签来自哪里?如何排除?

我目前正在开发的网站是: http://www.machinelearning.berlin

【问题讨论】:

  • 请不要在截图中发布代码。它们无法被搜索或复制,并且可用性差。相反,将代码作为文本直接粘贴到您的问题中。如果选择它并单击{} 按钮或Ctrl+K,则代码块将缩进四个空格,这将导致其呈现为代码。
  • 即使您的配置文件显示您正在使用主题 minima,您的标记屏幕截图仍显示 Arcana by HTML5 UP.. 另外确保您的文件中没有 BOM 序列

标签: html css format markdown jekyll


【解决方案1】:

Jekyll 真的很直截了当。不幸的是,一些聪明人(Jekyll 的建筑师)决定创建主题并将它们与每个新项目捆绑在一起。恕我直言,这是一个很大的错误。这导致许多人从他们不理解的代码开始,甚至更糟糕的是,他们不理解的结构。这句话完美地证明了这一点:

列表样式:无;因为 ul 元素来自渲染到网站头部的一些内联样式。真不知道出处,大概是主旋律吧?

因此,对于任何有类似问题并了解基本 HTML 和 CSS 的人来说,这是一条信息:Jekyll 真的很简单。如果您从 Jekyll 开始,请不要使用主题。开始你的项目是空的。这种方法将为您节省大量时间和挫败感。此外,它将让您深入了解 Jekyll 是什么以及它是如何工作的。以后你会感谢我的。

PS。回答您的问题:我可以向您保证,您的神秘代码属于您(未)选择的主题。

【讨论】:

  • 非常感谢您的评论。我跳进了这个项目,所以我从它离开的地方开始。然后您会建议将其重置为“无主题”项目并从头开始做所有事情吗?或者只是从头开始制作新的东西(网站现在不是那么大:machinelearning.berlin)?那么是否有可能像在 github 上一样拥有漂亮的格式化降价,而无需进一步努力?
  • 没有什么是不努力的。但如果可能的话,我会重新开始/清理并复制您需要的样式表。
猜你喜欢
  • 2011-04-07
  • 2019-01-13
  • 1970-01-01
  • 2023-03-21
  • 1970-01-01
  • 2019-10-05
  • 1970-01-01
  • 1970-01-01
  • 2014-06-30
相关资源
最近更新 更多