Hi All,
Given the way the conversation has evolved I think it may be worth revisiting another viewpoint to see if anybody has any nice ideas. As things are, regardless of the complexities of parsing and inline vs. block elements etc., just considering the user experience when running org-fill on an example like the one below, the behaviour isn't /nice/. Might there be some way we could allow for people who are used to LaTeX and/or like \[ ... \] to have fill behaviour that leaves \[ ... \] blocks alone? My original idea was changing how org-fill works for everyone, the discussion has gone on to changing \[ ... \] to a block element -- both of these seem to have rather significant issues. Ihor came up with the idea of making org-fill something more customisable by the user, so that someone could have this behaviour without making Org behave un-idiomatically for everyone. I proposed maybe just having a setting could be a halfway house between my original patch and his idea. Does anybody have any other thoughts? > If you’re wondering why I’m so opposed to the current behaviour, that is > probably > best explained by a more realistic demo that what I have in the commit > message. > > ┌──── > │ Since \(\cos\) is an even function, we can negate the numerator of the > argument > │ without changing the result, giving > │ \[ > │ \cos \left( \pi \frac{C_1-x}{2C_1+D} \right) \ , \quad C_1 = \frac{D}{2}. > │ \] > │ this will be positive over \(x \in (0,D)\), and so we can rewrite > \(\tilde{y}\) as, > │ \[ > │ \tilde{y}(x) = \frac{2D}{\pi} \log \cos \left( \pi > \frac{\frac{D}{2}-x}{2D} \right) + C_2. > │ \] > │ Once again considering that \(y(0)=y(D)=0\), it is clear that > │ \[ > │ C_2 = - \frac{2D}{\pi} \log \cos \left( \frac{\pi}{4} \right) = - > \frac{2D}{\pi} \log 2^{-\frac{1}{2}} = \frac{D}{\pi} \log 2. > │ \] > │ The complete solution for \(\tilde{y}\) is hence, > │ \[ > │ \tilde{y} = \frac{2D}{\pi} \log \cos \left( \pi \frac{D-2x}{4D} \right) + > \frac{D}{\pi} \log 2. > │ \] > └──── > is currently filled to > ┌──── > │ Since \(\cos\) is an even function, we can negate the numerator of the > argument > │ without changing the result, giving \[ \cos \left( \pi \frac{C_1-x}{2C_1+D} > │ \right) \ , \quad C_1 = \frac{D}{2}. \] this will be positive over \(x \in > (0,D)\), > │ and so we can rewrite \(\tilde{y}\) as, \[ \tilde{y}(x) = \frac{2D}{\pi} > \log \cos \left( \pi > │ \frac{\frac{D}{2}-x}{2D} \right) + C_2. \] Once again considering that > │ \(y(0)=y(D)=0\), it is clear that \[ C_2 = - \frac{2D}{\pi} \log \cos \left( > │ \frac{\pi}{4} \right) = - \frac{2D}{\pi} \log 2^{-\frac{1}{2}} = > \frac{D}{\pi} \log 2. > │ \] The complete solution for \(\tilde{y}\) is hence, \[ \tilde{y} = > \frac{2D}{\pi} \log \cos > │ \left( \pi \frac{D-2x}{4D} \right) + \frac{D}{\pi} \log 2. \] > └──── -- Timothy