OpenUserJS.org icon indicating copy to clipboard operation
OpenUserJS.org copied to clipboard

Autolink username via the `@username` syntax miss

Open Martii opened this issue 11 years ago • 14 comments

@swole_hamster is showing as @swole_hamster ... EDIT: ... from here.

Ref:

  • https://github.com/OpenUserJs/OpenUserJS.org/commit/091ef9cb40ea716fd30c138a7fb87b2bae0bb9c7 (miss here probably because tokens are split with regular expression look-ahead non-capture default from here ... or try to use marked lexer?)
  • https://github.com/OpenUserJs/OpenUserJS.org/commit/6d31f785ce562ccbe820e66fa2d7f85fea5f7930 (possibly revert until a work-around or fix is found)

Trace:

> renderer.text()
Crowd Task Google Search Link by @swole
> renderer.text()
_hamster

Martii avatar Sep 04 '15 05:09 Martii

And another one with [email protected] here.

Possibly need to see if there is a look ahead and a look behind option... and during require a space before the at symbol.

Martii avatar Oct 08 '15 11:10 Martii

To stop matching email addresses replace the regex here with this: /(?:^|\s)@([^\s\\\/:*?\'\"<>|#;@=&]+)/

I'm not sure why the underscore is breaking the match yet.

sizzlemctwizzle avatar Oct 19 '15 19:10 sizzlemctwizzle

I'm not sure why the underscore is breaking the match yet.

The reason is in the trace message... e.g. the package is splitting a "chunk", processing that "chunk", and we're missing it due to routine we are using with it... this is why it would be useful to have a look ahead and look behind with that package so we could see if the "chunk" needs aggregation.

Martii avatar Oct 19 '15 19:10 Martii

To be fair. The text rendering method isn't one listed in the official api. I found it by going through the source of the package.

sizzlemctwizzle avatar Oct 19 '15 19:10 sizzlemctwizzle

The html renderer method would work, but I was trying to avoid linking in code and pre blocks.

sizzlemctwizzle avatar Oct 19 '15 19:10 sizzlemctwizzle

We could probably do it in here but skip when aType === 'html' so we don't do it twice.

sizzlemctwizzle avatar Oct 19 '15 19:10 sizzlemctwizzle

I'll take this issue since it was my feature.

sizzlemctwizzle avatar Oct 19 '15 19:10 sizzlemctwizzle

but I was trying to avoid linking in code and pre blocks.

Might be a little irritating when we get notifications (#15 and/or #242) but may not... since I can divine this is another reason why you wanted this feature. ;)

Martii avatar Oct 19 '15 19:10 Martii

@sizzlemctwizzle Should this be autolinking in code md blocks? e.g. @sizzlemctwizzle ??

Martii avatar Nov 23 '15 00:11 Martii

@sizzlemctwizzle Cc: @Zren

Do either of you know if there is an equivalent of DocumentFragment in node (preferably native)? It seems that we need to check the parent node to see if it's a pre or code tag... if so don't do the replacing. Using a regular expression with dynamic content can get tricky. Back on USO I started using a document fragment to detect things... in this case we would possibly need to modify the text nodes then export out the innerHTML equivalent, assuming there is one.

Closest non-native I have found is html-document but that says it is only a partial implementation.

Martii avatar Nov 23 '15 05:11 Martii

I do see a xml parser/serializer at xmldomᴳᴴ (with xpathᴳᴴ)... it seems to me that express should have this as a method somewhere though. e.g. convert a string to a DOM and a DOM to a string for html (poorly formed) and xml (strictly formed).

Martii avatar Nov 23 '15 07:11 Martii

Another miss at https://openuserjs.org/scripts/TimidScript/%5BTS%5D_Pixiv++/issues/Pixivv++#comment-15140bea129 with a trailing comma.

Moving this to later... @sizzlemctwizzle I would suggest not implementing notifications until this is finalized... there's a bunch of work to do with some research before we can implement that feature correctly.

Martii avatar Nov 25 '15 22:11 Martii

Ref:

  • https://www.npmjs.com/package/jsdom perhaps on the DOM angle.

Martii avatar Oct 10 '17 12:10 Martii

Moving this to GH dev discussion.

Currently @_foo_ and @~foo~ is an issue still.

I think what should happen is:

  1. Sanitize the content
  2. Replace the @mentions
  3. Render with marked

... or ...

  1. Replace the @mentions
  2. Render with marked
  3. Sanitize the content

Currently it:

  1. Renders with marked
  2. Sanitizes the content
  3. Replaces the @mentions

Notes:

  • Be careful not to bust rendering... I seem to recall there was a prior issue on order. This concept will need to be thoroughly tested.

Refs:

  • Current code point at https://github.com/OpenUserJS/OpenUserJS.org/blob/b54f20a7d37f53e34e7c5f7033b1723264e46dd9/libs/markdown.js#L67-L70

Martii avatar Oct 23 '17 21:10 Martii