chore: fmt
This commit is contained in:
parent
c5fc886786
commit
f3ddfde201
@ -4,5 +4,5 @@ module.exports = {
|
||||
singleQuote: true,
|
||||
semi: false,
|
||||
arrowParens: 'avoid',
|
||||
plugins: ['prettier-plugin-sh'],
|
||||
plugins: [],
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
"test": "test"
|
||||
},
|
||||
"scripts": {
|
||||
"fmt": "bun fmt",
|
||||
"fmt": "bun bun/fmt.js",
|
||||
"build": "bun x spago build",
|
||||
"test": "bun x spago test"
|
||||
},
|
||||
|
@ -2,22 +2,21 @@ import cheerio from 'cheerio'
|
||||
|
||||
// Attributes
|
||||
export const attrImpl = function (nothing, just, name, cheerioInst) {
|
||||
|
||||
if (cheerioInst.length > 0) {
|
||||
const value = cheerioInst.attr(name);
|
||||
return value != null ? just(value) : nothing;
|
||||
const value = cheerioInst.attr(name)
|
||||
return value != null ? just(value) : nothing
|
||||
}
|
||||
|
||||
return nothing;
|
||||
return nothing
|
||||
}
|
||||
|
||||
export const hasClassImpl = function (className, cheerioInst) {
|
||||
return cheerioInst.hasClass(className);
|
||||
return cheerioInst.hasClass(className)
|
||||
}
|
||||
|
||||
// Traversing
|
||||
export const findImpl = function (selector, cheerioInst) {
|
||||
return cheerioInst.find(selector);
|
||||
return cheerioInst.find(selector)
|
||||
}
|
||||
|
||||
export const parent = function (cheerioInst) {
|
||||
@ -54,7 +53,7 @@ export const eqImpl = function(index, cheerioInst) {
|
||||
|
||||
// Rendering
|
||||
export const htmlImpl = function (nothing, just, cheerioInst) {
|
||||
return cheerioInst.length ? just(cheerioInst.html()) : nothing;
|
||||
return cheerioInst.length ? just(cheerioInst.html()) : nothing
|
||||
}
|
||||
|
||||
export const text = function (cheerioInst) {
|
||||
@ -63,5 +62,5 @@ export const text = function(cheerioInst) {
|
||||
|
||||
// Miscellaneous
|
||||
export const length = function (cheerioInst) {
|
||||
return cheerioInst.length;
|
||||
return cheerioInst.length
|
||||
}
|
||||
|
@ -26,8 +26,9 @@ import Data.Maybe (Maybe(..))
|
||||
foreign import data Cheerio :: Type
|
||||
|
||||
-- Attributes
|
||||
foreign import attrImpl :: forall a.
|
||||
Fn4 (Maybe a) (a -> Maybe a) String Cheerio (Maybe String)
|
||||
foreign import attrImpl
|
||||
:: forall a
|
||||
. Fn4 (Maybe a) (a -> Maybe a) String Cheerio (Maybe String)
|
||||
|
||||
-- | Gets an attribute value from the first selected element, returning
|
||||
-- | Nothing when there are no selected elements, or when the first selected
|
||||
@ -60,8 +61,9 @@ eq :: Int -> Cheerio -> Cheerio
|
||||
eq = runFn2 eqImpl
|
||||
|
||||
-- Rendering
|
||||
foreign import htmlImpl :: forall a.
|
||||
Fn3 (Maybe a) (a -> Maybe a) Cheerio (Maybe String)
|
||||
foreign import htmlImpl
|
||||
:: forall a
|
||||
. Fn3 (Maybe a) (a -> Maybe a) Cheerio (Maybe String)
|
||||
|
||||
-- | Gets an html content string from the first selected element, returning
|
||||
-- | Nothing when there are no selected elements.
|
||||
|
@ -30,8 +30,9 @@ selectDeep :: Array String -> CheerioStatic -> Cheerio
|
||||
selectDeep = runFn2 selectDeepImpl
|
||||
|
||||
-- Rendering
|
||||
foreign import htmlImpl :: forall a.
|
||||
Fn3 (Maybe a) (a -> Maybe a) Cheerio (Maybe String)
|
||||
foreign import htmlImpl
|
||||
:: forall a
|
||||
. Fn3 (Maybe a) (a -> Maybe a) Cheerio (Maybe String)
|
||||
|
||||
html :: Cheerio -> Maybe String
|
||||
html = runFn3 htmlImpl Nothing Just
|
||||
|
@ -169,4 +169,5 @@ suites = do
|
||||
# parent
|
||||
# children
|
||||
# first
|
||||
# text)
|
||||
# text
|
||||
)
|
||||
|
@ -1,7 +1,8 @@
|
||||
module Test.HtmlEx where
|
||||
|
||||
htmlEx :: String
|
||||
htmlEx = """
|
||||
htmlEx =
|
||||
"""
|
||||
<ul id="fruits">
|
||||
<li class="apple">Apple</li>
|
||||
<li class="orange">Orange</li>
|
||||
|
Loading…
Reference in New Issue
Block a user