{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import html\n", "import re" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# A small script to efficiently extract the courseware latex macros\n", "def decode(s):\n", " d = html.unescape(s)\n", " def remove_html(html):\n", " if not html: return html\n", " innerText = re.compile('').sub('', html)\n", " while innerText.find('>') >= 0:\n", " text = re.compile('<[^<>]+?>').sub('', innerText)\n", " if text == innerText:\n", " break\n", " innerText = text\n", "\n", " return innerText.strip()\n", " d = remove_html(d)\n", " d = d.replace(\"\\\\(\", \"$\").replace(\"\\\\)\", \"$\")\n", " d = d.replace(\"\\n\", \"\\n\\n\")\n", " return d" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "s = \"\"\"\n", "<p>Soient \\(V\\) un \\(\\mathbb{R}\\)-espace vectoriel et \\(S\\subset V\\) une collection de vecteurs dans \\(V.\\) On dit que \\(S\\) est <em>lin&eacute;airement d&eacute;pendante</em> (ou <em>li&eacute;e</em>) s'il existe des vecteurs distincts \\(v_1,\\ldots,v_r\\in S\\) et des scalaires \\(\\lambda_1,\\ldots,\\lambda_r\\in \\mathbb{R}\\) non tous nuls tels que \\(\\lambda_1v_1+\\cdots+\\lambda_rv_r=0.\\) (Autrement dit, s'il existe une combinaison lin&eacute;aire (non triviale) de vecteurs de \\(S\\) qui se r&eacute;duit au vecteur nul.) S'il n'existe pas de tels vecteurs dans \\(S,\\) alors on dit que \\(S\\) est <em>lin&eacute;airement ind&eacute;pendante</em> (ou <em>libre</em>).</p>\n", "<h3><span style="text-decoration: underline; color: #ff6600;">REMARQUE 2 :</span></h3>\n", "<p>Si \\(0\\in S,\\) alors \\(S\\) est li&eacute;e car \\(\\lambda\\cdot 0=0\\) pour tout \\(\\lambda\\in \\mathbb{R}.\\)</p>\n", "<p>&nbsp;</p>\n", "</div>\n", "\"\"\"\n", "\n", "print(decode(s))" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from IPython.display import display, Markdown, Latex\n", "\n", "display(Markdown(decode(s)))" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.8" } }, "nbformat": 4, "nbformat_minor": 4 }