Conversation
mtsmfm
left a comment
There was a problem hiding this comment.
Great work!
But TableOfContentsPages#call method is difficult and complex for me 😢
|
|
||
| request = context[:request] | ||
|
|
||
| current_page = if request.params.key?(:page) |
There was a problem hiding this comment.
How about passing context expressly (:page, :public_id etc) instead of :request?
It is difficult for me to find what params this plugin needs 😕
There was a problem hiding this comment.
I want to use full functionalities of request in this plugin.
But in fact, this plugin uses some functionalities of request.
|
I've fixed and pushed changes. |
|
|
||
| @context = { | ||
| full_text: @post.body, | ||
| fullpath: request.fullpath, |
There was a problem hiding this comment.
Hmm, I want to have uniform name
(fulltext and fullpath) or (full_text and full_path)
but fulltextdoesn't make sence...
| @post.pages.page(params[:page]).per(1) | ||
| end | ||
|
|
||
| @context = { |
There was a problem hiding this comment.
How about markdown_context ?
markdown_context is straightforward I think.
@context -> @markdown_context It's straightforward.
Because `full_text` and `fullpath` don't have same form. It's very confusing us.
| end | ||
| end | ||
|
|
||
| sub_test_case "toc" do |
There was a problem hiding this comment.
[rubocop]
- Metrics/BlockLength: Block has too many lines. [114/25]
| data("page1" => [1, 0, ["title"]], | ||
| "page2" => [2, 1, ["title-2"]], | ||
| "page3" => [3, 2, ["title-3", "title-3-1", "title-3-2"]]) | ||
| test "multiple pages with complex source" do |(page, index, expected_header_ids)| |
There was a problem hiding this comment.
[rubocop]
- Metrics/BlockLength: Block has too many lines. [36/25]
| page_separated_nodes = [] | ||
| condition = 1.upto(6).map {|n| "./following::h#{n}" }.join("|") | ||
| html.search("//comment()[contains(.,\"nextpage\")]").map do |comment_element| | ||
| page_separated_nodes << comment_element.search(condition).first |
There was a problem hiding this comment.
page_separated_nodes = html.search("//comment()[contains(.,\"nextpage\")]").map do |comment_element|
comment_element.search(condition).first
end| end | ||
| headers[id] += 1 | ||
| header_content = header_node.children.first | ||
| # TODO: Arrange indent level |
There was a problem hiding this comment.
This is for generated html indentation.
It is not important.
`#at` returns first element which is matched condition.
| headers_per_page = Hash.new {|h, k| h[k] = [] } | ||
| ul_list = Hash.new {|h, k| h[k] = UnorderedList.new } | ||
| ul_list[1] = UnorderedList.new(html_class: toc_class) | ||
| # rubocop:disable Metrics/BlockLength |
There was a problem hiding this comment.
[rubocop]
- Lint/UnneededDisable: Unnecessary disabling of
Metrics/BlockLength.
|
|
||
| def to_html | ||
| if @items.empty? | ||
| %Q(<li>#{@header.link}</li>) |
There was a problem hiding this comment.
[rubocop]
- Style/UnneededPercentQ: Use
%Qonly for strings that contain both single quotes and double quotes, or for dynamic strings that contain double quotes. :ref
ul must not be child of ul directry.
| (previous_level + 1).upto(header.level) do |level| | ||
| ul_list[level - 1] << ul_list[level] | ||
| end | ||
| else |
There was a problem hiding this comment.
[rubocop]
- Style/EmptyElse: Redundant
else-clause.
|
I got 500 error when I previewed a post has following body: |
|
This change needs daimon_markdown 0.7.0 or later
|
Click here if you want to create rubocop's auto-correct Pull Request See the documentation if you want to get more information about auto-correct. |
|
|
||
| test "extra white spaces in page separator" do | ||
| # in this case page separator doesn't work | ||
| body =<<~BODY |
There was a problem hiding this comment.
[rubocop]
- Style/SpaceAroundOperators: Surrounding space missing for operator
=. :ref

This is a daimon_markdown plugin.