mirror of
https://github.com/Hopiu/python-markdown-oembed.git
synced 2026-03-16 22:10:24 +00:00
Merge branch 'master' of https://github.com/Hopiu/python-markdown-oembed
This commit is contained in:
commit
dd567e7013
11 changed files with 144 additions and 3 deletions
5
.gitignore
vendored
5
.gitignore
vendored
|
|
@ -2,7 +2,10 @@
|
|||
.idea
|
||||
/dist
|
||||
/.eggs
|
||||
/venv
|
||||
venv
|
||||
*.pyc
|
||||
*.egg
|
||||
*.egg-info
|
||||
*.coverage
|
||||
*.swp
|
||||
*.swo
|
||||
|
|
|
|||
27
flake.lock
Normal file
27
flake.lock
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1698611440,
|
||||
"narHash": "sha256-jPjHjrerhYDy3q9+s5EAsuhyhuknNfowY6yt6pjn9pc=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "0cbe9f69c234a7700596e943bfae7ef27a31b735",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
||||
29
flake.nix
Normal file
29
flake.nix
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
description = "Oembed plugin flake";
|
||||
inputs = {
|
||||
nixpkgs.url = github:NixOS/nixpkgs/nixos-unstable;
|
||||
};
|
||||
outputs = { self, nixpkgs }:
|
||||
let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [];
|
||||
};
|
||||
pythonPackages = pkgs.python3Packages;
|
||||
system = "x86_64-linux";
|
||||
in rec {
|
||||
devShell.x86_64-linux = pkgs.mkShell {
|
||||
buildInputs = [
|
||||
pkgs.python3
|
||||
pkgs.python3Packages.pip
|
||||
];
|
||||
shellHook = ''
|
||||
export PS1='\u@md-oembed \$ '
|
||||
export PIP_PREFIX=$(pwd)/venv/pip_packages
|
||||
export PYTHONPATH="$PIP_PREFIX/${pkgs.python3.sitePackages}:$PYTHONPATH"
|
||||
export PATH="$PIP_PREFIX/bin:$PATH"
|
||||
unset SOURCE_DATE_EPOCH
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
9
src/python_markdown_oembed_extension/__init__.py
Normal file
9
src/python_markdown_oembed_extension/__init__.py
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from python_markdown_oembed_extension.oembedextension import OEmbedExtension
|
||||
|
||||
|
||||
VERSION = '0.2.2'
|
||||
|
||||
|
||||
def makeExtension(**kwargs):
|
||||
return OEmbedExtension(**kwargs)
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
from markdown import Extension
|
||||
import oembed
|
||||
from mdx_oembed.endpoints import DEFAULT_ENDPOINTS
|
||||
from mdx_oembed.inlinepatterns import OEmbedLinkPattern, OEMBED_LINK_RE
|
||||
from python_markdown_oembed_extension.endpoints import DEFAULT_ENDPOINTS
|
||||
from python_markdown_oembed_extension.inlinepatterns import OEmbedLinkPattern, OEMBED_LINK_RE
|
||||
|
||||
|
||||
class OEmbedExtension(Extension):
|
||||
|
|
@ -36,3 +36,4 @@ class OEmbedExtension(Extension):
|
|||
for endpoint in (allowed_endpoints or []):
|
||||
consumer.addEndpoint(endpoint)
|
||||
return consumer
|
||||
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<p>In this video Jakob Zinsstag introduces the topic of the course. You will
|
||||
discover that the relationship between humans and animals is manifold.
|
||||
{.lead}</p>
|
||||
<p><figure class="oembed ratio ratio-16x9"><iframe src="https://player.vimeo.com/video/734276368?h=f29c542352&app_id=122963" width="426" height="240" frameborder="0" allow="autoplay; fullscreen; picture-in-picture" title="One-Health_Tales_EN_1-02"></iframe></figure> </p>
|
||||
<p>Have a look at the farm of Jakob Zinsstag’s cousin in the Canton of Jura,
|
||||
Switzerland. Different animals create different feelings: there are those we
|
||||
love, some provoke fears and others will be eaten. Jakob Zinsstag shares the
|
||||
personal experiences he has had with animals. </p>
|
||||
<p><strong>How do you categorise your own experience with animals?</strong></p>
|
||||
12
src/python_markdown_oembed_extension/tests/test_markdown.md
Normal file
12
src/python_markdown_oembed_extension/tests/test_markdown.md
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
In this video Jakob Zinsstag introduces the topic of the course. You will
|
||||
discover that the relationship between humans and animals is manifold.
|
||||
{.lead}
|
||||
|
||||

|
||||
|
||||
Have a look at the farm of Jakob Zinsstag’s cousin in the Canton of Jura,
|
||||
Switzerland. Different animals create different feelings: there are those we
|
||||
love, some provoke fears and others will be eaten. Jakob Zinsstag shares the
|
||||
personal experiences he has had with animals.
|
||||
|
||||
**How do you categorise your own experience with animals?**
|
||||
21
src/python_markdown_oembed_extension/tests/test_markdown.py
Normal file
21
src/python_markdown_oembed_extension/tests/test_markdown.py
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import markdown, yaml, requests_mock
|
||||
from python_markdown_oembed_extension.oembedextension import OEmbedExtension
|
||||
from python_markdown_oembed_extension.endpoints import VIMEO
|
||||
|
||||
|
||||
def test_full():
|
||||
with ( requests_mock.Mocker() as m
|
||||
, open('./src/python_markdown_oembed_extension/tests/vimeoMock.yaml', 'r') as vm
|
||||
, open('./src/python_markdown_oembed_extension/tests/test_markdown.md', 'r') as md
|
||||
, open('./src/python_markdown_oembed_extension/tests/test_expectedHtml.html', 'r') as expectedHtml
|
||||
):
|
||||
|
||||
yml = yaml.safe_load(vm)
|
||||
m.get(yml['request'], json=yml['response'])
|
||||
|
||||
mdString = md.read()
|
||||
htmlString = markdown.markdown(mdString, extensions=[OEmbedExtension()])
|
||||
print(htmlString)
|
||||
|
||||
assert htmlString == expectedHtml.read().rstrip()
|
||||
|
||||
30
src/python_markdown_oembed_extension/tests/vimeoMock.yaml
Normal file
30
src/python_markdown_oembed_extension/tests/vimeoMock.yaml
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
---
|
||||
request: 'https://vimeo.com/734276368/f29c542352'
|
||||
response:
|
||||
account_type: 'live_premium'
|
||||
author_name: 'NMC Universität Basel'
|
||||
author_url: 'https://vimeo.com/newmediacenterunibasel'
|
||||
description: ''
|
||||
duration: 282
|
||||
height: 240
|
||||
html: >-
|
||||
<iframe
|
||||
src="https://player.vimeo.com/video/734276368?h=f29c542352&app_id=122963"
|
||||
width="426" height="240" frameborder="0" allow="autoplay; fullscreen; picture-in-picture"
|
||||
title="One-Health_Tales_EN_1-02"
|
||||
>
|
||||
</iframe>
|
||||
is_plus: '0'
|
||||
provider_name: 'Vimeo'
|
||||
provider_url: 'https://vimeo.com/'
|
||||
thumbnail_height: 166
|
||||
thumbnail_url: 'https://i.vimeocdn.com/video/1480489232-5ca2d723cadc09ae077c8b437581e84bd0485049780c60e218986fda60881110-d_295x166'
|
||||
thumbnail_url_with_play_button: 'https://i.vimeocdn.com/filter/overlay?src0=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F1480489232-5ca2d723cadc09ae077c8b437581e84bd0485049780c60e218986fda60881110-d_295x166&src1=http%3A%2F%2Ff.vimeocdn.com%2Fp%2Fimages%2Fcrawler_play.png'
|
||||
thumbnail_width: 295
|
||||
title: 'One-Health_Tales_EN_1-02'
|
||||
type: 'video'
|
||||
upload_date: '2022-07-28 04:16:03'
|
||||
uri: '/videos/734276368:f29c542352'
|
||||
version: '1.0'
|
||||
video_id: 734276368
|
||||
width: 426
|
||||
Loading…
Reference in a new issue