File tree Expand file tree Collapse file tree
resources/js/components/matchmaking Expand file tree Collapse file tree Original file line number Diff line number Diff line change 7171 class =" relative flex-grow text-slate-500 text-[16px] leading-[22px] mb-2 overflow-hidden"
7272 style =" height : auto "
7373 >
74- <div v-html =" tool.description" />
74+ <div v-html =" formatMultiline( tool.description) " />
7575
7676 <div
7777 v-if =" needShowMore"
@@ -121,6 +121,19 @@ export default {
121121 };
122122 },
123123 methods: {
124+ escapeHtml (value = ' ' ) {
125+ return String (value)
126+ .replace (/ &/ g , ' &' )
127+ .replace (/ </ g , ' <' )
128+ .replace (/ >/ g , ' >' )
129+ .replace (/ "/ g , ' "' )
130+ .replace (/ '/ g , ' '' );
131+ },
132+ formatMultiline (value ) {
133+ if (! value) return ' ' ;
134+ const normalized = String (value).replace (/ \r\n ? / g , ' \n ' );
135+ return this .escapeHtml (normalized).replace (/ \n / g , ' <br>' );
136+ },
124137 computeDescriptionHeight () {
125138 const containerEl = this .$refs .descriptionContainerRef ;
126139 const descriptionEl = this .$refs .descriptionRef ;
Original file line number Diff line number Diff line change 1717 <p
1818 v-if =" isOrganisation"
1919 class =" text-[#20262C] font-normal text-2xl p-0 mb-10"
20- v-html =" data.description"
20+ v-html =" formatMultiline( data.description) "
2121 />
2222
2323 <h3
7272 <p
7373 v-for =" detail in item.list"
7474 class =" p-0 pb-4 w-full"
75- v-html =" detail"
75+ v-html =" formatMultiline( detail) "
7676 />
7777 </div >
7878 </div >
113113 <p
114114 v-if =" isOrganisation"
115115 class =" p-0 text-slate-500 text-xl font-normal"
116- v-html =" data.description"
116+ v-html =" formatMultiline( data.description) "
117117 />
118118 </div >
119119 </div >
@@ -307,6 +307,20 @@ export default {
307307 }
308308 };
309309
310+ const escapeHtml = (value = ' ' ) =>
311+ String (value)
312+ .replace (/ &/ g , ' &' )
313+ .replace (/ </ g , ' <' )
314+ .replace (/ >/ g , ' >' )
315+ .replace (/ "/ g , ' "' )
316+ .replace (/ '/ g , ' '' );
317+
318+ const formatMultiline = (value ) => {
319+ if (! value) return ' ' ;
320+ const normalized = String (value).replace (/ \r\n ? / g , ' \n ' );
321+ return escapeHtml (normalized).replace (/ \n / g , ' <br>' );
322+ };
323+
310324 const orgData = computed (() => {
311325 const org = profileData .value ;
312326 if (org .type !== ' organisation' ) return null ;
@@ -510,6 +524,7 @@ export default {
510524 showAboutIndexes,
511525 handleToggleAbout,
512526 setDescriptionRef,
527+ formatMultiline,
513528 };
514529 },
515530};
You can’t perform that action at this time.
0 commit comments