Giter Club home page Giter Club logo

Comments (11)

pjkaufman avatar pjkaufman commented on September 21, 2024

Hey @RyotaUshio , I think I am having trouble following why hyphens would be usend instead of their fullwidth equivalent. Could you elaborate on this?

from obsidian-linter.

RyotaUshio avatar RyotaUshio commented on September 21, 2024

@pjkaufman Thank you for your attention. To be honest, I'm not sure about the exact reason.
But I'm pretty sure that at least 99% of us Japanese use half-width hyphens - instead of the full-width βˆ’ in this situation.

One reason I've come up with is that the full-width hyphen is much harder or more tedious to type than the half-width hyphen.
This is due to our keyboard layout and the nature of Japanese IMEs.
In my quick test, the full-width one required 7 keystrokes while the half-width one required only one.

from obsidian-linter.

pjkaufman avatar pjkaufman commented on September 21, 2024

Hey @RyotaUshio , do you think it would make sense to expose the punctuation/symbol list for English letter symbols to check for around the CJK characters?

For example, right now that logic lives here:

const head = /(\p{sc=Han}|\p{sc=Katakana}|\p{sc=Hiragana}|\p{sc=Hangul})( *)(\[[^[]*\]\(.*\)|`[^`]*`|\w+|[-+'"([Β₯$]|\*[^*])/gmu;
const tail = /(\[[^[]*\]\(.*\)|`[^`]*`|\w+|[-+;:'"Β°%$)\]]|[^*]\*)( *)(\p{sc=Han}|\p{sc=Katakana}|\p{sc=Hiragana}|\p{sc=Hangul})/gmu;
// inline math, inline code, markdown links, and wiki links are an exception in that even though they are to be ignored we want to keep a space around these types when surrounded by CJK characters
const regexEscapedIgnoreExceptionPlaceHolders = `${IgnoreTypes.link.placeholder}|${IgnoreTypes.inlineMath.placeholder}|${IgnoreTypes.inlineCode.placeholder}|${IgnoreTypes.wikiLink.placeholder}`.replaceAll('{', '\\{').replaceAll('}', '\\}');
const ignoreExceptionsHead = new RegExp(`(\\p{sc=Han}|\\p{sc=Katakana}|\\p{sc=Hiragana}|\\p{sc=Hangul})( *)(${regexEscapedIgnoreExceptionPlaceHolders})`, 'gmu');
const ignoreExceptionsTail = new RegExp(`(${regexEscapedIgnoreExceptionPlaceHolders})( *)(\\p{sc=Han}|\\p{sc=Katakana}|\\p{sc=Hiragana}|\\p{sc=Hangul})`, 'gmu');
const addSpaceAroundChineseJapaneseKoreanAndEnglish = function(text: string): string {
return text.replace(head, '$1 $3').replace(tail, '$1 $3');
};
let newText = ignoreListOfTypes([IgnoreTypes.italics, IgnoreTypes.bold], text, addSpaceAroundChineseJapaneseKoreanAndEnglish);
newText = newText.replace(ignoreExceptionsHead, '$1 $3').replace(ignoreExceptionsTail, '$1 $3');
newText = updateItalicsText(newText, addSpaceAroundChineseJapaneseKoreanAndEnglish);
newText = updateBoldText(newText, addSpaceAroundChineseJapaneseKoreanAndEnglish);
.

Essentially there are two sets of punctuation that are looked at:

  • Punctuation/symbols before CJK that are considered to be English: -+'"([Β₯$]
  • Punctuation/symbols after CJK that are considered to be English: -+;:'"Β°%$)]

Note: I think * is also checked for, but I think I would keep that hidden since it is a part of a markdown syntax check which could get hairy to try to allow the user to customize.

I can expose these two values as a list of characters to consider to be English when they are found in their respective locations. This would also fix #1036 .

How does that sound? Any suggestions around this?

from obsidian-linter.

pjkaufman avatar pjkaufman commented on September 21, 2024

A dev note: I will need to handle an empty list to make sure that we do not end up with an empty capture group since I think that is invalid in regex. So I need to handle that to make sure someone does not hose the linter's ability to run by doing that.

from obsidian-linter.

RyotaUshio avatar RyotaUshio commented on September 21, 2024

By "expose" do you mean adding a setting to customize the list?

from obsidian-linter.

pjkaufman avatar pjkaufman commented on September 21, 2024

Yes. Sorry. I forgot to say that it would be a user setting that would be a text box with all of those characters in it that could be edited. It is not a list in the way it would be displayed in the UI.

from obsidian-linter.

pjkaufman avatar pjkaufman commented on September 21, 2024

I think I have the code ready for this kind of change, but I need to test in Obsidian and with a couple of edge cases to make sure it does not die. Once I do that, I will go ahead and see about making the change. But if you want to give feedback on what I have written above, feel free to do so.

from obsidian-linter.

RyotaUshio avatar RyotaUshio commented on September 21, 2024

Thanks for elaborating, it sounds great! I really appreciate your quick work πŸ™

from obsidian-linter.

pjkaufman avatar pjkaufman commented on September 21, 2024

No problem. Today I am trying to knock out some issues and requests before I do the next release and start focusing back on better handling of mass linting operations.

from obsidian-linter.

pjkaufman avatar pjkaufman commented on September 21, 2024

I have merged the change in question. It should be on master and go out in the next release. It looks to be working, but there may be some issues with it. Feel free to let us know if there are any issues.

from obsidian-linter.

RyotaUshio avatar RyotaUshio commented on September 21, 2024

Thank you so much!! From my quick test, it seems to be working perfectly. I'll let you know if I noticed anything.

from obsidian-linter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.