mirror of
https://github.com/discourse/discourse.git
synced 2025-02-20 11:48:26 -06:00
FIX: inline oneboxer not applying to lists
This commit is contained in:
parent
f6bc572fb8
commit
a4e1920604
@ -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++){
|
||||
|
@ -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>')
|
||||
|
Loading…
Reference in New Issue
Block a user