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

inline classes, #to_adoc, consistency renames #33

Merged
merged 2 commits into from
Apr 23, 2024

Conversation

xyz65535
Copy link
Contributor

Metanorma PR checklist

- metanorma#31 added classes for inline elements
- metanorma#10 added #to_adoc to Coradoc::Document classes based upon reverse_adoc code
- renamed numbered/unnumbered to ordered/unordered for consistency with metanorma/asciidoc
lib/coradoc/document/inline/anchor.rb Outdated Show resolved Hide resolved
lib/coradoc/document/audio.rb Outdated Show resolved Hide resolved
anchor = @id ? "[[#{@id}]]\n" : ""
title = ".#{@title}\n" unless @title.empty?
"\n\n#{anchor}#{title}====\n" << lines << "\n====\n\n"
end
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's separate these into different classes. The number of ---- / ___ etc. can change, e.g. 3, 4, 5, 6, 10. But always matching in begin/end.

Copy link
Contributor

Choose a reason for hiding this comment

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

Moved to #41 .

lib/coradoc/document/header.rb Outdated Show resolved Hide resolved
end
def to_adoc
content = Coradoc::Generator.gen_adoc(@content)
"#{content[/^\s*/]}*#{content.strip}*#{content[/\s*$/]}"
Copy link
Contributor

Choose a reason for hiding this comment

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

An inline bold element can be wrapped with *...* or **...** (doubled) in this case:

*bold* itself

attached**bold**here

Similarly for italics and monospace.

Copy link
Contributor

Choose a reason for hiding this comment

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

Moved to #43.

lib/coradoc/document/paragraph.rb Outdated Show resolved Hide resolved
lib/coradoc/document/table.rb Outdated Show resolved Hide resolved
lib/coradoc/document/table.rb Outdated Show resolved Hide resolved
end

def level
@level ||= level_from_string
end

def to_adoc
content = Coradoc::Generator.gen_adoc(@content)
Copy link
Contributor

Choose a reason for hiding this comment

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

I want to differentiate @content being String content or Coradoc objects.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

differentiate in what way? @content can be both strong or Coradoc object because Coradoc::Generator.gen_adoc takes care of Coradoc objects, arrays, strings, nil

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't like the ambiguity of taking into different classes into this method. Can we use different methods for different types of input?

Copy link
Contributor Author

@xyz65535 xyz65535 Apr 19, 2024

Choose a reason for hiding this comment

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

Yes, goal would be for each method to be able to check if argument has one specific class?

About the class Title, now that I think about it, @content should not be a string but TextElement instead. Or am I wrong and it can be just a string.

Copy link
Contributor

Choose a reason for hiding this comment

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

It should be a TextElement, you’re right, because it can contain inline formatting like bold/italics and sup/sub etc.

opts = %{options="#{@options.join(',')}"}
end

[anchor, title, "video::", @src, "[", opts, "]"].join("")
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we need to define the options.

Options need to be validated, e.g. height/width can be auto or a pixel number. When given unknown options we should reject.

Copy link
Contributor

Choose a reason for hiding this comment

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

Moved to #42.

@ronaldtse
Copy link
Contributor

Merging first.

@ronaldtse ronaldtse merged commit 5c6be7e into metanorma:main Apr 23, 2024
13 of 14 checks passed
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.

None yet

2 participants