node-sql-parser icon indicating copy to clipboard operation
node-sql-parser copied to clipboard

Request for help. My product manager has requested to preserve line breaks in SQL expressions, but the content I obtained through parser.sqlify no longer contains any line breaks.

Open jxh150535011 opened this issue 1 year ago • 2 comments

Original requirement: The product manager wants users to input custom expressions, and the frontend performs formatting validation, field validation, and provides shortcuts for syntax input. I have successfully addressed these requirements using this library. For example, when performing field validation, I return the fields in the form of [xx] and later dynamically replace these [xx] with <span title="xx does not exist">xx</span> using regular expressions. Of course, I have taken into account the risk of HTML injection.

Now the problem is, when users input line breaks, for example, some users may input very long expressions and expect to preserve some basic formatting. However, when using sqlify, the line breaks and content indentation are lost. Can you please advise on how to proceed?"

jxh150535011 avatar Dec 04 '23 11:12 jxh150535011

原始需求: 产品经理希望让用户输入自定义表达式,前端进行格式校验、字段校验、快捷的语法输入,这些我用这个库都很好的解决了。例如字段校验的时候,我是将字段返回成[xx] 的形式,在后续通过正则来动态替换这些[xx] => <span title="xx does not exist">xx</span>,当然我已经有效的考虑了html注入的风险。` 现在问题是,当用户输入换行符,例如 有些用户在输入表达式的时候可能非常的长,所以期望保留一些基本的格式,这个时候进行 sqlify ,这个换行 或内容缩进就都没了,请问我该怎么办 ”

jxh150535011 avatar Dec 04 '23 11:12 jxh150535011

https://github.com/cchepelov/node-sql-parser/pull/1

cchepelov avatar Mar 12 '24 00:03 cchepelov