FIX: inline oneboxer not applying to lists

This commit is contained in:
Sam 2017-08-02 16:10:08 -04:00
parent f6bc572fb8
commit a4e1920604
2 changed files with 15 additions and 3 deletions

View File

@ -12,10 +12,9 @@ function applyOnebox(state, silent) {
for(let i=1;i<state.tokens.length;i++) {
let token = state.tokens[i];
let prev = state.tokens[i-1];
let prevAccepted = prev.type === "paragraph_open" && prev.level === 0;
let mode = prevAccepted ? ONEBOX : INLINE;
let mode = prev.type === "paragraph_open" && prev.level === 0 ? ONEBOX : INLINE;
if (token.type === "inline" && prevAccepted) {
if (token.type === "inline") {
let children = token.children;
for(let j=0;j<children.length-2;j++){

View File

@ -838,6 +838,19 @@ HTML
expect(PrettyText.cook("<img src='a'>\nhttp://a.com")).to include('onebox')
end
it 'handles mini onebox' do
SiteSetting.enable_inline_onebox_on_all_domains = true
InlineOneboxer.purge("http://cnn.com")
stub_request(:head, "http://cnn.com").to_return(status: 200)
stub_request(:get, "http://cnn.com").
to_return(status: 200, body: "<html><head><title>news</title></head></html>", headers: {})
expect(PrettyText.cook("- http://cnn.com\n- a http://cnn.com").split("news").length).to eq(3)
expect(PrettyText.cook("- http://cnn.com\n - a http://cnn.com").split("news").length).to eq(3)
end
it "can handle bbcode" do
expect(PrettyText.cook("a[b]b[/b]c")).to eq('<p>a<span class="bbcode-b">b</span>c</p>')
expect(PrettyText.cook("a[i]b[/i]c")).to eq('<p>a<span class="bbcode-i">b</span>c</p>')