@@ -19,7 +19,7 @@ $(() => {
1919 const $tgt = $ ( ev . target ) ;
2020 const $button = $tgt . is ( 'a' ) ? $tgt : $tgt . parents ( 'a' ) ;
2121 const action = $button . attr ( 'data-action' ) ;
22-
22+
2323 /** @type {JQuery<HTMLTextAreaElement | HTMLInputElement> } */
2424 const $field = $ ( '.js-post-field' ) ;
2525
@@ -33,7 +33,7 @@ $(() => {
3333 heading : [ '\n# ' , null ] ,
3434 hr : [ '\n\n-----\n\n' , null ] ,
3535 table : [ '\n\n| Title1 | Title2 |\n|- | - |\n| row1_1 | row1_2 |\n\n' , null ] ,
36- mathjax : [ '$' , '$' ]
36+ mathjax : [ '$' , '$' ] ,
3737 } ;
3838
3939 if ( Object . keys ( actions ) . indexOf ( action ) !== - 1 ) {
@@ -58,7 +58,7 @@ $(() => {
5858 case 66 :
5959 $ ( '[data-action="bold"]' ) . click ( ) ;
6060 break ;
61-
61+
6262 case 73 :
6363 $ ( '[data-action="italic"]' ) . click ( ) ;
6464 break ;
@@ -123,12 +123,13 @@ $(() => {
123123 } ) ;
124124
125125 QPixel . addPrePostValidation ( ( text ) => {
126- // This regex catches Markdown images with no or default alt text.
127- const altRegex = / ! \[ (?: I m a g e _ a l t _ t e x t ) ? \] (?: \( . + (? ! \\ \) ) \) | \[ .+ (? ! \\ \] ) \] ) / gi;
126+ // catch Markdown images with no or default alt text: https://regex101.com/r/ubcVn4/2
127+ const altRegex = / ! \[ (?: I m a g e _ a l t _ t e x t ) ? \] (?: \( [ ^ \) ] + ? \) | \[ .+ (? ! \\ \] ) \] ) / gi;
128128 if ( text . match ( altRegex ) ) {
129- const message = `It looks like you're posting an image with no alt text. Alt text is important for ` +
130- `accessibility. Consider adding alt text to the images in your post - ` +
131- `<a href="/help/alt-text">read this help article</a> for details and help writing alt text.` ;
129+ const message =
130+ `It looks like you're posting an image with no alt text. Alt text is important for ` +
131+ `accessibility. Consider adding alt text to the images in your post - ` +
132+ `<a href="/help/alt-text">read this help article</a> for details and help writing alt text.` ;
132133 return [ false , [ { type : 'warning' , message } ] ] ;
133134 }
134135 else {
0 commit comments