Addressing Hyperlink Formatting Issue with Double Comma (e.g., M.Kn) in NodeBB v1.18.5
-
Hello, I'm encountering an issue with my project on NodeBB v1.18.5. The problem arises when a user attempts to respond to a topic, and their response contains a double degree in the name (e.g., Johndoe S.H., M.Kn), wherein the M.Kn is automatically transformed into a hyperlink, as seen in this question.
I've attempted to address this by implementing an edit in the admin panel. Specifically, while the post is still in the queue awaiting approval, the admin would manually edit any instances of double degrees by replacing the period with a special character
.
(e.g., M.Kn).However, the client prefers a simpler solution. Therefore, I'm exploring the possibility of creating a function within NodeBB to automatically handle this issue. Is there an alternative approach to resolving this problem?
or its possible when the user make post/topic and the description has a function to convert period into special character
.
? -
@wnfdh2 the issue is not that there is a comma preceding the degree, but simply that
.kn
is a valid top level domain, so it is transformed into a hyperlink.The simplest thing for you to do is create a plug-in that listens to the hook fired on post creation, and modify the content as you already do manually.
To be completely honest with you I have absolutely no idea how changing the comma to the escaped character would cause the affected text to not turn into a hyperlink.
-
Mr. @julian , I've completed my plugin/hook integration in my NodeBB. When attempting to reply, the plugin functions as intended (I've tested by logging the data, and it's functioning properly). However, the parser isn't effectively converting periods into special characters when the data is posted hyperlinks persist. I'm curious about which hooks to utilize for processing when a user posts or replies to a topic. I've experimented with filter:parse.post, action:topic.reply, action:topic.save, and action:topic.post, but the resulting value continues to contain hyperlinks. Any guidance on this matter would be greatly appreciated.
this bellow is my code hook/plugin to escape period to special character:
this bellow is my configuration hooks in plugin.jsons (line 9):
and here the console result when i try to post topic:
the result still got hyperlink, can anyone tell to me what wrong in my code. thanks
-
@clover try changing your hook function to edit
postData
in place and return it directly, rather than creating a new object. -
Thank you for your guidance, Mr. @PitaJ, but despite making the adjustment to return the postData directly, I'm still encountering the same outcome.
Below is the updated code snippet of my function:
And here is the resulting output:
Could you confirm whether the approach I've taken aligns with your recommendation or if there's a misstep?
-
@wnfdh2 yoyo need to move your plugin so it has a greater priority than the markdown plugin. Right now, the markdown is being parsed first so you already have the link when it comes to you.