def fix_idef(): models.InputDefinition.objects.all().delete() idefs = list() for article in wiki_models.Article.objects.all(): md = ArticleMarkdown(article, preview=True) md.convert(article.current_revision.content) for name, val in md.defs.items(): idefs.append(update_inputdef(article, name, val.getExprStack())) for idef in idefs: expand_inputdef(idef)
def post_article_revision_save(**kwargs): arev = kwargs['instance'] md = ArticleMarkdown(arev.article, preview=True) md.convert(arev.content) with transaction.atomic(): old = InputDefinition.objects.filter(article=arev.article).exclude(name__in=md.defs) if old.exists(): logger.info("delete definition(s) {}".format([str(o) for o in old])) old.delete() for idef in [utils.update_inputdef(arev.article, name, val.getExprStack()) for name, val in md.defs.items()]: utils.expand_inputdef(idef)
def test_do_not_modify_extensions(self, settings): extensions = ['footnotes', 'attr_list', 'sane_lists'] settings.MARKDOWN_KWARGS = {'extensions': extensions} number_of_extensions = len(extensions) ArticleMarkdown(None) self.assertEqual(len(extensions), number_of_extensions)
def db_get_article_markdown(article, user): md = ArticleMarkdown(article, preview=True, user=user) md.convert(article.current_revision.content) return md
def test_do_not_modify_extensions(self, settings): extensions = ["footnotes", "attr_list", "sane_lists"] settings.MARKDOWN_KWARGS = {"extensions": extensions} number_of_extensions = len(extensions) ArticleMarkdown(None) self.assertEqual(len(extensions), number_of_extensions)
def dispatch(self, request, article, *args, **kwargs): self.md = ArticleMarkdown(article, preview=True) self.md.convert(article.current_revision.content) return super(DisplayDataView, self).dispatch(request, article, *args, **kwargs)