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

Exec function in core package #469

Closed
2 tasks done
antfu opened this issue Jan 2, 2020 · 1 comment · Fixed by #473
Closed
2 tasks done

Exec function in core package #469

antfu opened this issue Jan 2, 2020 · 1 comment · Fixed by #473

Comments

@antfu
Copy link
Member

antfu commented Jan 2, 2020

Describe your issue/suggestions

Currently, we only have auto numbers (and bools) conversion to hanzi in online ide. Not in cli, in browser runtime and other interfaces like vscode and sublime plugins.

I propose to extract the functionality and expose it in the core package allowing other interfaces to reuse this feature. This can make it more wenyan-ish without care about the internal details about it.

Meanwhile, this can also solve the floating-point testing issue, #457.

I would love to make a PR for this.

More related issues #465, antfu/wenyan-lang-vscode#12


Technical

New function execute

Allowing users to directly execute the source code through the API. This will be a simple wrapper of compile and evalCompiled

function execute (source, options = { hanzinize: true, ...other options in compile })

New function evalCompiled

This is basically all the changes happen. It will hijack the console.log and outputs hanzi result when the hanzinize option is set.

function evalCompiled (compiledCode, options = { hanzinize: true })

New CLI options --hanzinize

Default to true. Only works for executing mode

New Browser Runtime script attr hanzinize

Default to true.

<script type="application/wenyan" scoped hanzinize="false">
吾有一數。曰三。書之。
</script>

Checklist

Before you create this issue, Please make sure ALL the following items are checked

  • If this is a feature request, it's NOT listed Here
  • If this is a bug report, it's NOT listed Here
@LingDong-
Copy link
Member

👍 Sounds great! Please feel free to make a PR.
I'm not sure how readable the word hanzinize though, it sounds fun, but we might also consider something plain like outputHanzi. Let's think about it a bit more.
Thanks a lot and good luck with the PR, let me know if there's something I could help.

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 a pull request may close this issue.

2 participants