lsbardel / lucasbardella.com

My personal website
http://lucasbardella.com
0 stars 0 forks source link

Katex AngularJS #1

Open lsbardel opened 9 years ago

lsbardel commented 9 years ago

Feedbacks and Comments for http://lucasbardella.com/blog/2014/11/katex-angularjs

user3587412 commented 9 years ago

Hi,

Thanks for your article. I also made a custom directive based on your code. However, when i used "<" or ">" signs (e.g., <katex> 0 > p > 1 </katex>), the directive broke, probably because the <> signs are used for html tags. Would there be a way to work around this?

Thanks!

lsbardel commented 9 years ago

Looks like the only option is to fallback to MathJax by using begin{equation}

<div katex>
\begin{equation}
0 > p > \frac{1}{a}
\end{equation}
</div>

You may want to ask the question to the Katex developer for a better answer.

josuemontano commented 9 years ago

Great article, thanks! However I've got a problem, I render equations fetched from a DB so my controller looks like this

.controller('FormulaCrtl', ['$scope', function($scope) {
   // I really got this from a service
    $scope.formula = {
        title: 'Lorem ipsum',
        content: '<katex>d y_t = \alpha_t dt + \sigma_t d W_t</katex>'
    };
}])
.filter('html', ['$sce', function ($sce) { 
    return function (text) {
        return $sce.trustAsHtml(text);
    };    
}]);

When I render as <div ng-bind-html="article.content | html"></div> the equation is not rendered by your KaTeX directive, how could I solve it? Thanks again!