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

Refactor markdown-engine.ts by extracting custom markdown features into separate files #34

Merged
merged 7 commits into from
Jan 29, 2018

Conversation

kachkaev
Copy link
Collaborator

In response to #33

@kachkaev
Copy link
Collaborator Author

kachkaev commented Jan 18, 2018

I moved custom markdown features such as code fencing into separate files, which reduced the size of markdown-engine.ts from 2944 to 2599 lines of code. There're still quite a few options to make markdown-engine.ts even easier to edit, however, this initial refactoring can already make the difference. New markdown features easier to implement and the existing ones are better decoupled.

I've been using atom-beautify on file save, so some spacing has changed too. I'll be great to use similar coding style in future – I'm happy to reconfigure mine if you have a preference!


export default (md: MarkdownIt, config: MarkdownEngineConfig) => {
// @ts-ignore
md.inline.ruler.before('strikethrough', 'critic-markup', (state, silent) => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@shd101wyy could you please explain why this function returns boolean? According to a type definition in @types/markdown-it it is expected to return void. I had to add // @ts-ignore in several feature files to ignore build errors meanwhile. Is there any place in mume or markdown-it that is using the returned true / false? I could not find it.

@kachkaev
Copy link
Collaborator Author

kachkaev commented Jan 18, 2018

I've been using prettier Prettier in several javascript projects and quite enjoyed the way it enforces order in all the code. It turned out that prettier began to support typescript a few months back, so I added it to this PR. Two new commits add Prettier together to tslint, which is a helpful tool to spot imperfections that prettier cannot fix automatically. With these two new dependencies, an editor (Atom in my case) becomes much more responsive as the new code gets written. The more errors and warnings "as you go", the fewer errors in runtime and the easier it is to collaborate due to a community-enforced code standard.

@shd101wyy I'll be happy to help you with setting up prettier and tslint if you're new to these tools.

Copy link
Owner

@shd101wyy shd101wyy left a comment

Choose a reason for hiding this comment

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

I just merged shd101wyy/master branch to the branch of this pull request. Everything looks good to me. You can merge it whenever you want. Then I will go publish a new release. Thank you very much ;)

@kachkaev
Copy link
Collaborator Author

Great to hear that @shd101wyy! Will you be happy if I simply press "merge pull request" or do you expect me to rebase etc.?

@shd101wyy
Copy link
Owner

@kachkaev I think simply "merge pull request" is good enough. Thanks.

@kachkaev kachkaev merged commit ab802b6 into shd101wyy:master Jan 29, 2018
@kachkaev
Copy link
Collaborator Author

Done! Looking forward to send more PRs after the new release! Just holding on for now to avoid too much complexity in the git tree :–)

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